SFTP stuck at connect

When the application tries to connect, it gets stuck at sftp.connect. The application will not error out or anything. I’m thinking that it may be the prompt to save the server key. Any way to save that key or to go around this issue?

Hi,


Thank you for your inquiry.

Below is the sample code for your reference. Also check the below linked Technical Article on the subject.
http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/connect-to-secure-ftp-server-using-sftp.html

[C#]

string host = “host”;
int port = 22; // the default port
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
authenticationInfo.UserName = “ftpuser”;
authenticationInfo.Password = “pwd”;
if (publicKey == true)
{
Console.Write("\nEnter path to file containing publickey: ");
string path = “ssh.key”;
if (File.Exists(path))
authenticationInfo.LoadPrivateKey(path);
else
{
Console.WriteLine(“The specified file doesn’t exist. Publickey authentication will be disabled”);
}
}

// connecting to the server
SftpClient client = new SftpClient();
try
{
client.Connect(host, port, authenticationInfo);
Console.WriteLine(“Successfully connected”);
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}


If you are still unable to connect to Sftp. Then please share with us the version of your Aspose.Network assembly. Also tell us the server name, version and SFTP protocol version? If you manage to get a test account for us for few days, it will be more helpful.

The problem is that I don’t have the “.key” file. No point in doing the prompt if you don’t have it in the first place.

What happens is, when you connect to the server using a 3rd party FTP tool like Core FTP with SFTP capability, I get a prompt if I want to save the server key into the application (this is Core FTP) which saves it onto itself. I now have the key but the problem is how do you make it into a “.key” file?

Hi,

If your SFTP server does not require key authentication, then no key file is required. Only the correct credentials and host information are enough.

Could you please provide the sample code snippet that you are using? I just tested the below code with a local WinSSHD server and it worked without any problem. The same information when provided to FileZilla client, it worked as well.

string host = “192.168.0.10”;
int port = 22;
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
authenticationInfo.UserName = “My Username”;
authenticationInfo.Password = “my password”;
// I did not used key file, as my account does not require it
SftpClient client = new SftpClient();
client.Connect(host, port, authenticationInfo);

Hi


I have the same issue. There is no private key file needed, but when I use the SftpClient.Connect method, passing in the host, port, user and password as explained in this thread, the connect method just freezes - no errors.

Please help.

Hi Ross,


Please check your other thread where we have replied to your inquiry.

Regards,