Error when I open a session
Hello,
I want to connect to a SFTP to upload a file with C# and WinScp but i'm having a problem, i got this error ah the "session.open()" line :
My code is :
Even if I set an SSH key, I still get the same error, do you have an idea why ?
I want to connect to a SFTP to upload a file with C# and WinScp but i'm having a problem, i got this error ah the "session.open()" line :
Connection has been unexpectedly closed. Server sent command exit status 0.
My code is :
try { var sessionsOptions = new SessionOptions { Protocol = Protocol.Sftp, HostName = Settings.Default.p_credHost, UserName = Settings.Default.p_credName, Password = Settings.Default.p_credPass, PortNumber = 22, GiveUpSecurityAndAcceptAnySshHostKey = true }; using (var session = new Session()) { session.Open(sessionsOptions); var transferOptions = new TransferOptions {TransferMode = TransferMode.Binary}; session.PutFiles(localFile, string.Concat("/", newFile), true, transferOptions); } } catch (SessionException error) { MessageBox.Show(string.Concat("FTP Error : ", error.Message)); }
Even if I set an SSH key, I still get the same error, do you have an idea why ?