You can use the SshSession
class - a part of Rebex.Networking.dll
shared library, distributed as a part of all Rebex communication components, including Rebex FTP or Rebex Telnet.
To connect to an FTP or telnet server through an SSH server, use this code:
using Rebex.Net;
...
// connect to SSH server X
SshSession session = new SshSession();
session.Connect("X");
session.Authenticate(userNameForX, passwordForX);
// connect to FTP server A through SSH server X
Ftp ftp = new Ftp();
ftp.SetSocketFactory(session.ToSocketFactory()); // sets up tunneling through SSH
ftp.Connect("A");
ftp.Login(userNameForA, passwordForA);
...
// connect to telnet server B through SSH server X
Telnet telnet = new Telnet("B");
telnet.SetSocketFactory(session.ToSocketFactory()); // sets up tunneling through SSH
// start a Shell
Shell shell = telnet.StartShell();
...
// connect to SSH server C through SSH server X
Ssh ssh = new Ssh();
ssh.SetSocketFactory(session.ToSocketFactory()); // sets up tunneling through SSH
ssh.Connect("C");
ssh.Login("userNameForC", "passwordForC");
...
A VB.NET sample is available in another forum post.
Other Rebex components (SFTP, IMAP, POP3, SMTP) can also connect over an SSH session in the same way.