EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Connect via private key 10058 err

Posted: 11/10/2011 08:06:27
by Javier Piris (Basic support level)
Joined: 11/08/2011
Posts: 1

I can't make the code connect via private key. User and password works fine. I disabled user and password connection, to force it connect via private key and I'm always getting 10058 "Connection lost" error. I have no idea about what's going on.

This is the code I use.

            SftpClient.Address = txtServer.Text;
            SftpClient.Port = 22;
            SftpClient.UseInternalSocket = true;

            int i = SftpClient.Address.IndexOf(':');
            if (i > 0)
                SftpClient.Port = Int32.Parse(SftpClient.Address.Substring(i + 1, SftpClient.Address.Length - i - 1));
                SftpClient.Address = SftpClient.Address.Substring(0, i);

            SftpClient.AuthenticationTypes = SBSSHConstants.Unit.SSH_AUTH_TYPE_PUBLICKEY;

            TElSSHKey key = new TElSSHKey();
            TElSSHMemoryKeyStorage KeyStorage = new TElSSHMemoryKeyStorage();
            int err = key.LoadPrivateKey(txtKey.Text,"");
            if (err == 0)
                SftpClient.KeyStorage = KeyStorage;                
                catch (Exception ex)
                MessageBox.Show("Private key file could not be loaded due to error " + err.ToString());

I'm not sure if I should be using a passphrase for the private key, my IT team didn't say anything about it, it's supposed to be ok because error code is 0.
The error occurs when SftpClient.Open();
Posted: 11/10/2011 08:12:41
by Vsevolod Ievgiienko (Team)

Thank you for contacting us.

First of all try to check if you can connect using our demo that is located in \EldoS\SecureBlackbox.NET\Samples\C#\SFTPBlackbox\Client\SimpleSFTPClient. You should also check if you are able to connect to the server using another SFTP client.
Posted: 11/10/2011 08:20:44
by Eugene Mayevski (Team)

The very first thing to check is whether you specify the user name. Use of the key doesn't exclude necessity to set the user name.

In general errors of this kind (WinSock error 10058 happens when the server forcefully closes connection) happen due to badly written server software, which is not able to gracefully report the error before (or instead of) closing the socket. Consequently it's not possible to say anything about the reason of the problem in your case. In simplest case the key is just not known to the server, i.e. it can't authenticate you right but most likely the problem lies deeper.

Please contact server admin and ask him to check the log - maybe the server writes something about the reason. Also please post the value of ServerSoftwareName property (if you connect successfully with a password, you can read it).

Sincerely yours
Eugene Mayevski



Topic viewed 1558 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!