Error when trying to connect to SFTP Server

Sep 12, 2012 at 12:46 PM

Wow, there's really a lot going on over her :)

I just switched to SSH.NET after starting to implement SharpSSH and finding out that such things as deleting files are not very well handled in there.

So I just started by creating a simple connection to my sftp server with:

 

SftpClient sftpClient = new SftpClient(ftpHost, 22, ftpUser, ftpPassword);
sftpClient.Connect();
sftpClient.Disconnect();

 

Where ftpHost, ftpUser and ftpPassword are the same variables I used with SharpSSH and which worked perfectly actually. Now I'm getting an Exception when SSH.NET tries to connect:

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it::1:22
  at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
    at Renci.SshNet.Session.SocketConnect(String host, Int32 port)
    at Renci.SshNet.Session.Connect()
    at Renci.SshNet.BaseClient.Connect()
    at
...

Does anybody have a clue what the problem could be? As i said: when I use the same credentials with SharpSSH --> it still works.

Sep 12, 2012 at 12:57 PM
Do you get any information in the output window?

On Wednesday, September 12, 2012, platzh1rsch wrote:

From: platzh1rsch

Wow, there's really a lot going on over her :)

I just switched to SSH.NET after starting to implement SharpSSH and finding out that such things as deleting files are not very well handled in there.

So I just started by creating a simple connection to my sftp server with:

SftpClient sftpClient = new SftpClient(ftpHost, 22, ftpUser, ftpPassword);
sftpClient.Connect();
sftpClient.Disconnect();

Where ftpHost, ftpUser and ftpPassword are the same variables I used with SharpSSH and which worked perfectly actually. Now I'm getting an Exception when SSH.NET tries to connect:

System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it::1:22
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at Renci.SshNet.Session.SocketConnect(String host, Int32 port)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at
...

Does anybody have a clue what the problem could be? As i said: when I use the same credentials with SharpSSH --> it still works.

Read the full discussion online.

To add a post to this discussion, reply to this email (sshnet@discussions.codeplex.com)

To start a new discussion for this project, email sshnet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Sep 12, 2012 at 2:09 PM

Unfortunately this is no Console Application if you meant this. :)

If you didn't mean that, tell me. I'll provide as many information as I can.

Sep 12, 2012 at 2:20 PM

If you are using visual studio, you can see it in the Output Window, or using dbgview from sysinternals.

Take a look here and see what you can provide: http://sshnet.codeplex.com/workitem/1303

Sep 12, 2012 at 3:09 PM

What I get from the Output Window is this: "A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll"

Using the source code is - unfortunately - no option because the project was built with version 3.5 of the .Net Framework.

Thanks for your fast replies.

Nov 12, 2012 at 8:40 PM

Same problem here, did you ever figure this out Platzh?

Nov 12, 2012 at 8:48 PM

Unfortunately not.. I ended up using Tamir Gals SharpSSH library.

Although it was the fact that SSH.net should be the successor of that library that brought me here.

Nov 12, 2012 at 9:19 PM
Edited Nov 12, 2012 at 9:19 PM

Thanks Platzh, unfortunately the SharpSSH site seems to be messed up.  When I try and download the examples the sourceforge site goes into an infinite loop of "wait for download" and counts down for 5 seconds (tried it in IE and Chrome).  Direct link does the same.  Mirrors do the same.  Then when I tried downloading the NuGet package, I get a missing assembly exception:

Session.connect: System.IO.FileNotFoundException: Could not load file or assembly 'DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.File name: 'DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'   at Tamir.SharpSsh.jsch.jce.DH.getE()   at Tamir.SharpSsh.jsch.DHG1.init(Session session, Byte[] V_S, Byte[] V_C, Byte[] I_S, Byte[] I_C)   at Tamir.SharpSsh.jsch.Session.receive_kexinit(Buffer buf)   at Tamir.SharpSsh.jsch.Session.connect(Int32 connectTimeout)
=== Pre-bind state information ===LOG: User = PETERSCO\fbalasLOG: DisplayName = DiffieHellman, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (Fully-specified)LOG: Appbase = file:///D://bin/Debug/LOG: Initial PrivatePath = NULLCalling assembly : Tamir.SharpSSH, Version=1.1.1.13, Culture=neutral, PublicKeyToken=null.

So over all, Tamir's project seems to be in rougher shape.  I may have to dive into the code and figure out why this is happening.