0 votes
by (420 points)

I am getting the below exception. Connection was closed by the Server. Make sure you are connecting to SSH or SFTP Server
Exception happening straight after sftp connectivity part which is bolded. We are using Rebex version suited for our application which is in 3.5 framework version.
I am using below code:
objNewSFTP.Connect(SFTPHost, Convert.ToInt32(SFTPPort));

            SshPrivateKey privateKey = new SshPrivateKey(Convert.ToString(SFTPPvtKeyPath), Convert.ToString(SFTPPvtKeyPwd));

                         objNewSFTP.Login(Convert.ToString(SFTPUserName), Convert.ToString(SFTPPassword), privateKey);
Applies to: Rebex SFTP

1 Answer

0 votes
by (132k points)

This error occurs in Rebex SFTP when the server does not respond with a proper SSH server identification string that starts with "SSH-2.0-". Typically, this happens when trying to connect to a server that is not using SFTP/SSH. For example, connecting to an FTP server would produce this message.

What message do you receive when you connect to the server from Windows command line using the 'telnet' command? Does it start with "SSH-2.0-"?

by
Hi there,

I am also frequently getting the same issue when I connect o SFTP. Telnet command gave the message starts with SSH-2.0-. . below is my code

                ftp.Connect(server, port);
                if (keyFile == null || keyFile.Length==0)
                    ftp.Login(user, password);
                else
                    ftp.Login(user, new Rebex.Net.SshPrivateKey(keyFile, keyFilePassword));

Please let me know How can we fix this issue
by (5.1k points)
Hi Sreenath ,
Please create a communication log and send it to support@rebex.net.
https://www.rebex.net/kb/logging/
...