0 votes
by (150 points)
edited

Hello, Do you have a suggestion, how can i use rebex to achieve this. We have a one server (Say x ) through which we can access other servers (a,b,c). How can I run a command on server a , and ftp its contents to my machine using rebex dll

regards

1 Answer

+1 vote
by (144k points)
edited
 
Best answer

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.

by (150 points)
edited

Hi

I logged into a Server "A" using SSH conncetion using your Rebex. Now I need to login to Server "B" from here using SSH hostname username & password VB.net. Can you kindly post the code?

Thanks

by (18.0k points)
edited

A VB.NET sample is available in another forum post.

...