IOException System Source Stream Read Using Sharp SSH

I am currently facing a really strange problem in one of my projects.

I used Tamir Gal Sharp SSH Library in my code to upload some files to FTP. When I run the code in debug mode, everything works as it should. But when I build the solution and try it with this built-in version, I get a System.IO.IOException:

Tamir.SharpSsh.jsch.JSchException: Session.connect: System.IO.IOException: End of IO Stream Read at Tamir.SharpSsh.jsch.IO.getByte(Byte[] array, Int32 begin, Int32 length) at Tamir.SharpSsh.jsch.Session.read(Buffer buf) at Tamir.SharpSsh.jsch.User.Auth.start(Session session) at Tamir.SharpSsh.jsch.UserAuthNone.start(Session session) at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout) at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout) at Tamir.SharpSsh.jsch.SshBase.ConnectSession(Int32 tcpPort) at Tamir.SharpSsh.jsch.SshBase.Connect(Int32 tcpPort) at Tamir.SharpSsh.jsch.SshBase.Connect() 

There seems to be a problem with the data stream (Hello Captain Obvious! :)), so the program does not even install to complete the Connect method. I just don't understand why everything works during debugging. DLL files are copied correctly during the build process.

The code is as follows:

 sftpClient = new Sftp(this.ftpHost, this.ftpUser, this.ftpPassword); sftpClient.Connect(); 

All variables have the correct values, and I can connect to the SFTP server using them in a client such as Filezilla.

If anyone can give me a hint or had a similar problem, I would really appreciate every comment.

Thank you all in advance and have a nice day.

+4
source share
1 answer

My colleague just found a solution:

In SharpSSH you have 3 Dlls:

  • Org.Mentalis.Security.dll
  • Tamir.SharpSSH.dll
  • DiffieHellman.dll

Since I never had to reference Org.Mentalis.Security.dll in code, I completely forgot to copy it during the build process. Because of this, the entire security level that SharpSSH is enabled on is not available and what caused the error.

I hope this thread can help a few other forgetful people. :)

+19
source

Source: https://habr.com/ru/post/1437345/


All Articles