I am getting the exception "connection closed by the server .,make sure you are connecting to an SSH or SFTP server" while connecting to SFTP. It was working few days back without any issue. We are using Rebex 6.0.8372.0. Publc and Private Key pair was created and public key was shared to CB for whuitelisted. Afterwards with Username, pasword, private key path and password we are connecting to CB. please advise on the below asap
Below is th code we are using
string SFTPHost = Convert.ToString(ConfigurationSettings.AppSettings["SFTPHost"]);
string SFTPPort = Convert.ToString(ConfigurationSettings.AppSettings["SFTPPort"]);
string SFTPUserName = Convert.ToString(ConfigurationSettings.AppSettings["SFTPUserName"]);
string SFTPPassword = Convert.ToString(ConfigurationSettings.AppSettings["SFTPPassword"]);
string SFTPPvtKeyPath = Convert.ToString(ConfigurationSettings.AppSettings["SFTPPvtKeyPath"]);
string SFTPPvtKeyPwd = Convert.ToString(ConfigurationSettings.AppSettings["SFTPPvtKeyPwd"]);
//Updated by Alex on 31.01.2022 for SFTP Authentication with Private Key without loading PFX File End
IsActive = objNewSFTP.GetConnectionState();
WriteLog("ConnectSftp()-SFTP Connection State:" + objNewSFTP.GetConnectionState().Connected, false);
if (IsActive.Connected == false)
{
WriteLog("ConnectSftp()-SFTP Connectivity Attempted with SFTPHost:" + Convert.ToString(SFTPHost) + Environment.NewLine + "Port:" + Convert.ToInt32(SFTPPort) + "at " + DateTime.Now.ToString(), false); //Added by Alex on 31.1.2022
objNewSFTP.Connect(SFTPHost, Convert.ToInt32(SFTPPort));
WriteLog("ConnectSftp()-SFTP Connectivity Done Successfully at " + DateTime.Now.ToString(), false); //Added by Alex on 31.1.2022
//Added by Alex on 31.01.2022 for SFTP Authentication with Private Key without loading PFX File Start
WriteLog("ConnectSftp()-Private Key Details before loading-Private Key Path:" + Convert.ToString(SFTPPvtKeyPath) + Environment.NewLine + "at " + DateTime.Now.ToString(), false);
SshPrivateKey privateKey = new SshPrivateKey(Convert.ToString(SFTPPvtKeyPath), Convert.ToString(SFTPPvtKeyPwd));
WriteLog("ConnectSftp()-Private Key Details loaded successfully at " + DateTime.Now.ToString(), false);
WriteLog("ConnectSftp()-SFTP Authentication Details before Login-UserName:" + Convert.ToString(SFTPUserName) + Environment.NewLine + "at " + DateTime.Now.ToString(), false);
objNewSFTP.Login(Convert.ToString(SFTPUserName), Convert.ToString(SFTPPassword), privateKey);
//Added by Alex on 31.01.2022 for SFTP Authentication with Private Key without loading PFX File End
WriteLog("ConnectSftp()-Completed SFTP Authentication Process at " + DateTime.Now.ToString(), false);
}