A supplied public key was not accepted by the server or the user name is incorrect.

0 votes
asked Feb 22, 2012 by patibandha (180 points)
edited Mar 5, 2012

hi

I am using SFTP object. I am trying to connect to my SFTP server using Rebex test app and i am getting following error.

17:16:39.640 Info Info: Connecting to **********:29 using Sftp 2.0.4086.0.
17:16:40.562 Info SSH: Negotiation started.
17:16:42.750 Info SSH: Negotiation finished.
17:16:42.750 Info Info: Server: SSH-2.0-CoreFTP-0.2.2
17:16:42.750 Info Info: Fingerprint: bc:08:23:7f:20:59:99:85:7a:a8:60:a7:a6:52:13:50
17:16:42.750 Info Info: Cipher info: SSH 2.0, Diffie-Hellman-Group14-SHA1, RSA, aes256-cbc/aes256-cbc, SHA1/SHA1
17:17:01.532 Error SSH: Rebex.Net.SshException: A supplied public key was not accepted by the server or the user name is incorrect.
   at Rebex.Net.SshSession.cCIjvV(String , String , SshPrivateKey , SshGssApiCredentials )
17:17:01.532 Error Info: Rebex.Net.SshException: A supplied public key was not accepted by the server or the user name is incorrect.
   at Rebex.Net.SshSession.cCIjvV(String , String , SshPrivateKey , SshGssApiCredentials )
   at Rebex.Net.SshSession.Authenticate(String userName, String password, SshPrivateKey privateKey)
   at Rebex.Net.Sftp.Login(String userName, String password, SshPrivateKey privateKey)

while i try to connect this SFTP using WinSCP it is connecting fine..

can any one help me to find this issue..

Thanks

Applies to: Rebex SFTP

3 Answers

0 votes
answered Feb 22, 2012 by Tomas Knopp (58,890 points)
edited Feb 22, 2012

Hello and thanks for reporting this to us. However, we need to see more information so please log the communication again using

Rebex.FileLogWriter with Rebex.LogLevel.Debug

as described on the forum and post it here so that we are able to help you.

0 votes
answered Feb 22, 2012 by patibandha (180 points)
edited Feb 24, 2012

following is the log i m getting from the sample application given by Rebex

20:24:00.060 Info Info: Connecting to ftp.g-t-p.com:29 using Sftp 2.0.4086.0.
20:24:00.592 Debug SSH: Server is 'SSH-2.0-CoreFTP-0.2.2'.
20:24:00.607 Info SSH: Negotiation started.
20:24:00.904 Debug SSH: Negotiating key.
20:24:02.295 Debug SSH: Validating signature.
20:24:02.560 Info SSH: Negotiation finished.
20:24:02.576 Info Info: Server: SSH-2.0-CoreFTP-0.2.2
20:24:02.576 Info Info: Fingerprint: bc:08:23:7f:20:59:99:85:7a:a8:60:a7:a6:52:13:50
20:24:02.592 Info Info: Cipher info: SSH 2.0, Diffie-Hellman-Group14-SHA1, RSA, aes256-cbc/aes256-cbc, SHA1/SHA1
20:24:11.170 Debug SSH: Allowed authentication methods: password, publickey.
20:24:11.170 Debug SSH: Trying public key authentication for 'testsftp'.
20:24:11.451 Error SSH: Rebex.Net.SshException: A supplied public key was not accepted by the server or the user name is incorrect.
   at Rebex.Net.SshSession.cCIjvV(String , String , SshPrivateKey , SshGssApiCredentials )
20:24:11.451 Error Info: Rebex.Net.SshException: A supplied public key was not accepted by the server or the user name is incorrect.
   at Rebex.Net.SshSession.cCIjvV(String , String , SshPrivateKey , SshGssApiCredentials )
   at Rebex.Net.SshSession.Authenticate(String userName, String password, SshPrivateKey privateKey)
   at Rebex.Net.Sftp.Login(String userName, String password, SshPrivateKey privateKey)

let me know if any further detail required..

commented Feb 22, 2012 by Lukas Pokorny (92,430 points)
edited Feb 22, 2012

One more request: Please create a log with WinSCP as well and either post it here or mail it to support@rebex.net. By comparing the two logs, we should be able to spot some difference. Thanks!

commented Feb 24, 2012 by patibandha (180 points)
edited Feb 24, 2012

hi

i send detail log of WinSCP on given email.

pls. check

thanks.

0 votes
answered Feb 24, 2012 by Lukas Pokorny (92,430 points)
edited Mar 5, 2012

Thanks for the log! The following section looks very interesting:

. 2012-02-24 11:54:58.957 Reading private key file "C:\Rebex\GTP_Test\gtp_test_private.ppk"
! 2012-02-24 11:54:58.972 Using username "testsftp".
. 2012-02-24 11:54:59.207 Offered public key
. 2012-02-24 11:54:59.457 Offer of public key accepted
! 2012-02-24 11:54:59.457 Authenticating with public key "rsa-key-20120208"
. 2012-02-24 11:54:59.457 Prompt (3, SSH key passphrase, , Passphrase for key "rsa-key-20120208": )
! 2012-02-24 11:55:05.676 Access denied
. 2012-02-24 11:55:05.676 Access denied
. 2012-02-24 11:55:05.676 Prompt (7, SSH password, , &Password: )
. 2012-02-24 11:55:05.676 Using stored password.
. 2012-02-24 11:55:05.676 Sent password
. 2012-02-24 11:55:07.660 Access granted

This shows that WinSCP's public key authentication attempt was actually rejected as well (this corresponds to Rebex SFTP's attempt), but then the client tried password authentication and succeeded. This means there are two possibilities:

1) The server doesn't know anyhing about your public key, but the account password is sufficient for authentication. In this case, try calling Sftp.Login(userName, password) instead of Sftp.Login(userName, password, privateKey).

2) The server requires a public key authentication before password authentication can proceed, but reports "failure" error code instead of proper "partial success". Some of our clients have encountered such servers in the past. To solve this, the following workaround could be used:

   Sftp client = new Sftp();
   client.Connect(...);
   try
   {
         SshPrivateKey privateKey = new SshPrivateKey(keyPath, keyPassword);
         client.Login(userName, privateKey);
   }
   catch (SftpException)
   {
         client.Login(userName, password);
   }

Please note that there is a bug in Rebex SFTP v2.0.4086.0 that causes a NullReferenceException to be thrown when using this workaround. To solve this, I will e-mail you a link to the current build of Rebex SFTP that solves this issue.

commented Mar 5, 2012 by patibandha (180 points)
edited Mar 5, 2012

thanks..

this help me.. in my issue

...