System IOException Stream Read End with Sharp SSH
Asked Answered
T

1

5

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

I've implemented Tamir Gal's Sharp SSH Library in my code to upload some files per FTP. When I run the code in Debug Mode everything works just as it should. But when I build the solution and try it with that built 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()

It looks like there's a Problem with the Data Stream (Hello Captain Obvious! :) ), so the Program doesn't even establish to finish the Connect Method. I just don't get why everything works while debugging. The dlls get copied correctly in the building process.

The code looks like this:

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

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

If anybody could give me a hint or has had a similiar problem, I would be very thankful for every comment.

Thank you all in advance and have a nice day.

Touristy answered 2/10, 2012 at 8:38 Comment(1)
I had to test SSH using sharpsshtest.exe on a 2008r2 server after doing that this issues was fixed for me. Must need to register that dll or something to that effect.Fillagree
T
20

My colleague just found the solution:

In SharpSSH you have 3 Dlls:

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

Because I never had to reference Org.Mentalis.Security.dll in the code i totally forgot to copy it during the build process. Because of this the whole Security Layer which SharpSSH relays on wasn't accessible and that's what caused the error.

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

Touristy answered 2/10, 2012 at 11:54 Comment(1)
I used to do some work updating SharpSSH. I have a version that has everything in one DLL @ bitbucket.org/mattgwagner/sharpssh . I would also highly recommend you look at SSH.net on Codeplex for a far better, and maintained, SSH library.Mendoza

© 2022 - 2024 — McMap. All rights reserved.