All wodCrypt (12) wodSSH (10) wodSFTP (23) wodSSHServer (1) wodSSHTunnel (11) wodSSHpackage wodSFTPdll wodSSH.NET (10) wodSFTP.NET (24) wodFtpDLX.NET (22) wodWebServer.NET (10) wodAppUpdate (13) wodHttpDLX (8) wodFtpDLX (22) wodTelnetDLX wodFTPServer (3) wodWebServer (10) wodVPN wodXMPP (13) | All ** [Visual Basic] ** [C#] ** [VB.NET] ** PublicKey authentication
VB code
Dim WithEvents wodSSHTunnel1 As wodTunnelCom Private Sub Form_Load() Dim key As Keys Set wodSSHTunnel1 = New wodTunnelCom Set key = New Keys 'wodKeys component is part of wodSSHTunnel ActiveX component. 'Load private key from a file. key.Load "c:\private.pem", "weonlydo" 'weonlydo is private key password wodSSHTunnel1.HostName = "your_hostname" 'Select public key authentication. wodSSHTunnel1.Authentication = authPubkey wodSSHTunnel1.Login = "your_login" 'Connect private key from wodKeys to wodSSHTunnel. wodSSHTunnel1.PrivateKey = key wodSSHTunnel1.Connect End Sub 'Connected Event fires when wodSSHTunnel connects to a remote server. Private Sub wodSSHTunnel1_Connected() 'When you define a new channel as LocalListen then the local computer will bind a new socket to the LocalAddress interface 'on LocalPort and when a new connection arrives it will forward it to the SSH server at RemoteAddress on RemotePort. 'In this example we will forward port 80. So if there were any HTTP server on your server you can open is locally using http://127.0.0.1 'You will be using encrypted connection insread insecure Internet. wodSSHTunnel1.Channels.Add LocalListen, "127.0.0.1", 80, "0.0.0.0", 80 wodSSHTunnel1.Channels.StartAll 'Start channels End Sub 'Disconnected Event fires when wodSSHTunnel disconnects from the server. Private Sub wodSSHTunnel1_Disconnected(ByVal ErrorCode As Integer, ByVal ErrorText As String) If ErrorCode <> 0 Then MsgBox "DISCONNECTED: " & ErrorText 'Connection error is received here End If End Sub 'ChannelStop Event fires when a specific channel has stopped. Private Sub wodSSHTunnel1_ChannelStop(ByVal Chan As wodSSHTunnelCOMLib.IChannel, ByVal ErrorCode As Integer, ByVal ErrorText As String) Debug.Print "Channel stop " & ErrorText 'Channel error is received here End Sub 'UserConnected Event fires when a user connects to the listening channel. Private Sub wodSSHTunnel1_UserConnected(ByVal Chan As wodSSHTunnelCOMLib.IChannel, ByVal User As wodSSHTunnelCOMLib.IUser, ByVal ErrorCode As Integer, ByVal ErrorText As String) Debug.Print "User from " & User.HostName & " connected" End Sub 'UserDisconnected Event fires when a user disconnects from a channel. Private Sub wodSSHTunnel1_UserDisconnected(ByVal Chan As wodSSHTunnelCOMLib.IChannel, ByVal User As wodSSHTunnelCOMLib.IUser, ByVal ErrorCode As Integer, ByVal ErrorText As String) Debug.Print "User from " & User.HostName & " left " & ErrorText End Sub VB.NET code
Dim WithEvents wodSSHTunnel1 As wodSSHTunnelCOMLib.wodTunnelCom Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim key As wodKeys.Keys wodSSHTunnel1 = New wodSSHTunnelCOMLib.wodTunnelCom key = New wodKeys.Keys 'wodKeys component is part of wodSSHTunnel ActiveX component. 'Load private key from a file. key.Load("c:\private.pem", "weonlydo") 'weonlydo is private key password wodSSHTunnel1.Hostname = "your_hostname" 'Select public key authentication. wodSSHTunnel1.Authentication = wodSSHTunnelCOMLib.AuthenticationsEnum.authPubkey wodSSHTunnel1.Login = "your_login" 'Connect private key from wodKeys to wodSSHTunnel. wodSSHTunnel1.PrivateKey = key wodSSHTunnel1.Connect() End Sub 'Connected Event fires when wodSSHTunnel connects to a remote server. Private Sub wodSSHTunnel1_Connected() Handles wodSSHTunnel1.Connected 'When you define a new channel as LocalListen then the local computer will bind a new socket to the LocalAddress interface 'on LocalPort and when a new connection arrives it will forward it to the SSH server at RemoteAddress on RemotePort. 'In this example we will forward port 80. So if there were any HTTP server on your server you can open is locally using http://127.0.0.1 'You will be using encrypted connection insread insecure Internet. wodSSHTunnel1.Channels.Add(wodSSHTunnelCOMLib.ForwardTypesEnum.LocalListen, "127.0.0.1", 80, "0.0.0.0", 80) wodSSHTunnel1.Channels.StartAll() 'Start channels End Sub 'Disconnected Event fires when wodSSHTunnel disconnects from the server. Private Sub wodSSHTunnel1_Disconnected(ByVal ErrorCode As Short, ByVal ErrorText As String) Handles wodSSHTunnel1.Disconnected If ErrorCode <> 0 Then MsgBox("DISCONNECTED: " & ErrorText) 'Connection error is received here End If End Sub 'ChannelStop Event fires when a specific channel has stopped. Private Sub wodSSHTunnel1_ChannelStop(ByVal Chan As wodSSHTunnelCOMLib.Channel, ByVal ErrorCode As Short, ByVal ErrorText As String) Handles wodSSHTunnel1.ChannelStop Console.WriteLine("Channel stop " & ErrorText) 'Channel error is received here End Sub 'UserConnected Event fires when a user connects to the listening channel. Private Sub wodSSHTunnel1_UserConnected(ByVal Chan As wodSSHTunnelCOMLib.Channel, ByVal User As wodSSHTunnelCOMLib.User, ByVal ErrorCode As Short, ByVal ErrorText As String) Handles wodSSHTunnel1.UserConnected Console.WriteLine("User from " & User.Hostname & " connected") End Sub 'UserDisconnected Event fires when a user disconnects from a channel. Private Sub wodSSHTunnel1_UserDisconnected(ByVal Chan As wodSSHTunnelCOMLib.Channel, ByVal User As wodSSHTunnelCOMLib.User, ByVal ErrorCode As Short, ByVal ErrorText As String) Handles wodSSHTunnel1.UserDisconnected Console.WriteLine("User from " & User.Hostname & " left " & ErrorText) End Sub C# code
wodSSHTunnelCOMLib.wodTunnelCom wodSSHTunnel1; private void Form1_Load(System.Object sender, System.EventArgs e) { wodSSHTunnel1 = new wodSSHTunnelCOMLib.wodTunnelCom(); wodSSHTunnel1.Connected += new wodSSHTunnelCOMLib._IwodTunnelComEvents_ConnectedEventHandler(wodSSHTunnel1_Connected); wodSSHTunnel1.Disconnected += new wodSSHTunnelCOMLib._IwodTunnelComEvents_DisconnectedEventHandler(wodSSHTunnel1_Disconnected); wodSSHTunnel1.ChannelStop += new wodSSHTunnelCOMLib._IwodTunnelComEvents_ChannelStopEventHandler(wodSSHTunnel1_ChannelStop); wodSSHTunnel1.UserConnected += new wodSSHTunnelCOMLib._IwodTunnelComEvents_UserConnectedEventHandler(wodSSHTunnel1_UserConnected); wodSSHTunnel1.UserDisconnected += new wodSSHTunnelCOMLib._IwodTunnelComEvents_UserDisconnectedEventHandler(wodSSHTunnel1_UserDisconnected); //wodKeys component is part of wodSSHTunnel ActiveX component. //Load private key from a file. wodKeys.Keys key= new wodKeys.Keys(); key.Load("c:\\private.pem","weonlydo"); wodSSHTunnel1.Hostname = "your_hostname"; wodSSHTunnel1.Login = "your_login"; //Select public key authentication. wodSSHTunnel1.Authentication = wodSSHTunnelCOMLib.AuthenticationsEnum.authPubkey; //Connect private key from wodKeys to wodSSHTunnel. wodSSHTunnel1.PrivateKey = key; wodSSHTunnel1.Connect(wodSSHTunnel1.Hostname, wodSSHTunnel1.Port, wodSSHTunnel1.Protocol); } //Connected Event fires when wodSSHTunnel connects to a remote server. private void wodSSHTunnel1_Connected() { //When you define a new channel as LocalListen then the local computer will bind a new socket to the LocalAddress interface //on LocalPort and when a new connection arrives it will forward it to the SSH server at RemoteAddress on RemotePort. //In this example we will forward port 80. So if there were any HTTP server on your server you can open is locally using http://127.0.0.1 //You will be using encrypted connection insread insecure Internet. wodSSHTunnel1.Channels.Add(wodSSHTunnelCOMLib.ForwardTypesEnum.LocalListen, "127.0.0.1", 80, "0.0.0.0", 80); wodSSHTunnel1.Channels.StartAll(); //Start channels } //Disconnected Event fires when wodSSHTunnel disconnects from the server. private void wodSSHTunnel1_Disconnected(short ErrorCode, string ErrorText) { if (ErrorCode != 0) { MessageBox.Show("DISCONNECTED: " + ErrorText); //Connection error is received here } } private void wodSSHTunnel1_ChannelStop(wodSSHTunnelCOMLib.Channel Chan, short ErrorCode, string ErrorText) { Console.WriteLine("Channel stop " + ErrorText); //Channel error is received here } //UserConnected Event fires when a user connects to the listening channel. private void wodSSHTunnel1_UserConnected(wodSSHTunnelCOMLib.Channel Chan, wodSSHTunnelCOMLib.User User, short ErrorCode, string ErrorText) { Console.WriteLine("User from " + User.Hostname + " connected"); } //UserDisconnected Event fires when a user disconnects from a channel. private void wodSSHTunnel1_UserDisconnected(wodSSHTunnelCOMLib.Channel Chan, wodSSHTunnelCOMLib.User User, short ErrorCode, string ErrorText) { Console.WriteLine("User from " + User.Hostname + " left " + ErrorText); } |