0 votes
by (150 points)
edited

How to create another SSH connection to another from already created SSH server. I created SSH connection to SSH server A. And now I want to connect to SSH server B from A. Can you share sample VB code for this?

Thanks Harris

1 Answer

+1 vote
by (18.0k points)
edited

Here is a VB.NET example:

Imports Rebex.Net

Module Module1

Sub Main()

    'connect to SSH server A'
    Dim session As New SshSession()
    session.Connect("serverA", 22)
    session.Authenticate("userA", "passwordA")

    'connect to SSH server B through SSH server A'
    Dim client As New Ssh()
    client.SetSocketFactory(session.ToSocketFactory()) 'set up tunneling through SSH'
    client.Connect("serverB", 2222)
    client.Login("userB", "passwordB")

    'use the client here...'

End Sub

End Module

For compiling it, you have to reference following libraries:

  • Rebex.Common.dll
  • Rebex.Networking.dll
  • Rebex.SshShell.dll
  • Rebex.Terminal.dll

All these libraries are part of the Rebex SSH Shell package.

...