0 votes
by (320 points)
edited

I am trying to load a lot of data simultaneously to the server. To simulate this scenario when the following piece of code is run, At times the authentication succeeds, but at times the authentication fails saying bad credentials. Though they are the same credential:

    /* Simulating the scenario of file upload */
    for(;;)
    {
        test();
    }

    public void test()
    {
        bool newConnCreated = false;
        try
        {
            if (!checkState())
            {
                client.Connect("SFTP Server Name");
                newConnCreated = true;
            }

            client.Login("UsrName", "Password");
            client.Upload(@"C:\DataCollection\TestFiles\UploadTest1.txt", @"/", Rebex.IO.TraversalMode.MatchFilesShallow, Rebex.IO.TransferMethod.Copy, Rebex.IO.ActionOnExistingFiles.OverwriteAll);              
        }
        catch (Exception e)
        {
            Console.WriteLine("No connection");
        }
        finally
        {
            if (newConnCreated)
            {
                client.Disconnect();

            }
        }

    }

    public bool checkState()
    {
        bool state = false;
        try
        {
            client.CheckConnectionState();
            state = true;
        }
        catch(Exception e)
        {
            state = false;
        }
        return state;
    }

When this piece of code is used to upload a number of files subsequently, a few files get transferred as the credentials get authenticated. But in a few iterations it fails when we reach the line client.Login with the message: "A supplied password or user name is incorrect." System.Exception {Rebex.Net.SftpException} Am I missing something here? The credentials used are the exact ones, that passes at times and fails at times.

Adding the communication Logs as well:

2012-05-14 18:17:51.553 Opening log file.
2012-05-14 18:17:51.599 INFO Sftp(1)[10] Info: Connecting to mfttst.qualcomm.com:22 using Sftp 3.0.4498.1 (trial version).
2012-05-14 18:17:51.721 DEBUG Sftp(1)[10] SSH: Server is 'SSH-2.0-SFTP Server'.
2012-05-14 18:17:51.727 INFO Sftp(1)[10] SSH: Negotiation started.
2012-05-14 18:17:51.774 DEBUG Sftp(1)[10] SSH: Group exchange.
2012-05-14 18:17:51.785 DEBUG Sftp(1)[10] SSH: Negotiating key.
2012-05-14 18:17:51.905 DEBUG Sftp(1)[10] SSH: Validating signature.
2012-05-14 18:17:51.951 INFO Sftp(1)[10] SSH: Negotiation finished.
2012-05-14 18:17:51.951 INFO Sftp(1)[10] Info: Server: SSH-2.0-SFTP Server
2012-05-14 18:17:51.952 INFO Sftp(1)[10] Info: Fingerprint: 1f:9f:7b:a6:b2:23:b9:0a:f9:43:3c:b0:5b:20:82:01
2012-05-14 18:17:51.953 INFO Sftp(1)[10] Info: Cipher info: SSH 2.0, DiffieHellmanGroupExchangeSHA1, RSA, aes256-ctr/aes256-ctr, SHA1/SHA1
2012-05-14 18:17:54.113 INFO Sftp(1)[10] SSH: Received banner: SSH Server supporting SFTP and SCP 
2012-05-14 18:17:54.120 DEBUG Sftp(1)[10] SSH: Allowed authentication methods: password, publickey, keyboard-interactive.
2012-05-14 18:17:54.124 DEBUG Sftp(1)[10] SSH: Trying password authentication for 'qmt_b'.
2012-05-14 18:17:54.153 ERROR Sftp(1)[10] SSH: Rebex.Net.SshException: A supplied password or user name is incorrect.
   at Rebex.Net.SshSession.1QmUCN(String , String , SshPrivateKey , SshGssApiCredentials )
2012-05-14 18:18:23.954 Opening log file.
2012-05-14 18:18:23.998 INFO Sftp(1)[9] Info: Connecting to mfttst.qualcomm.com:22 using Sftp 3.0.4498.1 (trial version).
2012-05-14 18:18:24.122 DEBUG Sftp(1)[9] SSH: Server is 'SSH-2.0-SFTP Server'.
2012-05-14 18:18:24.127 INFO Sftp(1)[9] SSH: Negotiation started.
2012-05-14 18:18:24.175 DEBUG Sftp(1)[9] SSH: Group exchange.
2012-05-14 18:18:24.185 DEBUG Sftp(1)[9] SSH: Negotiating key.
2012-05-14 18:18:24.309 DEBUG Sftp(1)[9] SSH: Validating signature.
2012-05-14 18:18:24.349 INFO Sftp(1)[9] SSH: Negotiation finished.
2012-05-14 18:18:24.349 INFO Sftp(1)[9] Info: Server: SSH-2.0-SFTP Server
2012-05-14 18:18:24.350 INFO Sftp(1)[9] Info: Fingerprint: 1f:9f:7b:a6:b2:23:b9:0a:f9:43:3c:b0:5b:20:82:01
2012-05-14 18:18:24.351 INFO Sftp(1)[9] Info: Cipher info: SSH 2.0, DiffieHellmanGroupExchangeSHA1, RSA, aes256-ctr/aes256-ctr, SHA1/SHA1
2012-05-14 18:18:25.676 INFO Sftp(1)[9] SSH: Received banner: SSH Server supporting SFTP and SCP 
2012-05-14 18:18:25.684 DEBUG Sftp(1)[9] SSH: Allowed authentication methods: password, publickey, keyboard-interactive.
2012-05-14 18:18:25.685 DEBUG Sftp(1)[9] SSH: Trying password authentication for 'qmt_b'.
2012-05-14 18:18:25.712 ERROR Sftp(1)[9] SSH: Rebex.Net.SshException: A supplied password or user name is incorrect.
   at Rebex.Net.SshSession.1QmUCN(String , String , SshPrivateKey , SshGssApiCredentials )
2012-05-14 18:18:28.600 DEBUG Sftp(1)[9] SSH: Allowed authentication methods: password, publickey, keyboard-interactive.
2012-05-14 18:18:28.600 DEBUG Sftp(1)[9] SSH: Trying password authentication for 'qmt_b'.
2012-05-14 18:18:28.630 ERROR Sftp(1)[9] SSH: Rebex.Net.SshException: A supplied password or user name is incorrect.
   at Rebex.Net.SshSession.1QmUCN(String , String , SshPrivateKey , SshGssApiCredentials )
2012-05-14 18:18:31.204 DEBUG Sftp(1)[9] SSH: Allowed authentication methods: password, publickey, keyboard-interactive.
2012-05-14 18:18:31.204 DEBUG Sftp(1)[9] SSH: Trying password authentication for 'qmt_b'.
2012-05-14 18:18:31.233 ERROR Sftp(1)[9] SSH: Rebex.Net.SshException: Connection has been closed by the remote connection end; disconnected by application. Too many bad authentication attempts!.
   at Rebex.Net.SshSession.1xzy5U(Byte[] , Int32 , Int32 )
   at Rebex.Net.SshSession.i12XcZ(Byte[] , Int32 , Int32 )
   at Rebex.Net.SshSession.1rsOcLZ(1VEj6UZ , Object[] )
   at Rebex.Net.SshSession.2aErfC(OCfHX )
   at Rebex.Net.SshSession.283Jn3()
   at Rebex.Net.SshSession.VXRf6(String , String , Boolean )
   at Rebex.Net.SshSession.1QmUCN(String , String , SshPrivateKey , SshGssApiCredentials )
2012-05-14 18:18:31.236 ERROR Sftp(1)[9] Info: Rebex.Net.SshException: Connection has been closed by the remote connection end; disconnected by application. Too many bad authentication attempts!.
   at Rebex.Net.SshSession.1xzy5U(Byte[] , Int32 , Int32 )
   at Rebex.Net.SshSession.i12XcZ(Byte[] , Int32 , Int32 )
   at Rebex.Net.SshSession.1rsOcLZ(1VEj6UZ , Object[] )
   at Rebex.Net.SshSession.2aErfC(OCfHX )
   at Rebex.Net.SshSession.283Jn3()
   at Rebex.Net.SshSession.VXRf6(String , String , Boolean )
   at Rebex.Net.SshSession.1QmUCN(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)
2012-05-14 18:18:33.492 INFO Sftp(1)[9] Info: Connecting to mfttst.qualcomm.com:22 using Sftp 3.0.4498.1 (trial version).
2012-05-14 18:18:33.499 DEBUG Sftp(1)[9] SSH: Server is 'SSH-2.0-SFTP Server'.
2012-05-14 18:18:33.499 INFO Sftp(1)[9] SSH: Negotiation started.
2012-05-14 18:18:33.500 DEBUG Sftp(1)[9] SSH: Group exchange.
2012-05-14 18:18:33.509 DEBUG Sftp(1)[9] SSH: Negotiating key.
2012-05-14 18:18:33.622 DEBUG Sftp(1)[9] SSH: Validating signature.
2012-05-14 18:18:33.633 INFO Sftp(1)[9] SSH: Negotiation finished.
2012-05-14 18:18:33.634 INFO Sftp(1)[9] Info: Server: SSH-2.0-SFTP Server
2012-05-14 18:18:33.634 INFO Sftp(1)[9] Info: Fingerprint: 1f:9f:7b:a6:b2:23:b9:0a:f9:43:3c:b0:5b:20:82:01
2012-05-14 18:18:33.634 INFO Sftp(1)[9] Info: Cipher info: SSH 2.0, DiffieHellmanGroupExchangeSHA1, RSA, aes256-ctr/aes256-ctr, SHA1/SHA1
2012-05-14 18:18:34.754 INFO Sftp(1)[9] SSH: Received banner: SSH Server supporting SFTP and SCP 
2012-05-14 18:18:34.763 DEBUG Sftp(1)[9] SSH: Allowed authentication methods: password, publickey, keyboard-interactive.
2012-05-14 18:18:34.763 DEBUG Sftp(1)[9] SSH: Trying password authentication for 'qmt_b'.
2012-05-14 18:18:34.781 DEBUG Sftp(1)[9] SSH: Authentication successful.
2012-05-14 18:18:34.798 DEBUG Sf
Applies to: Rebex SFTP

2 Answers

+1 vote
by (144k points)
edited

Please try creating the log with LogLevel.Verbose level instead of LogLevel.Debug - then you will be able to see the contents of the actual authentication packet. If the content of these packets is identical (= they contain the same username and password), then I really see no reason for the behavior you observe. However, it would also mean that the problem is caused by something at the server (looking into the server log might be useful).

What's also interesting is the "Too many bad authentication attempts!" message in the log - this part of the error message was actually sent by the server and indicates that the server did indeed view those authentication attempts as "bad".

by (320 points)
edited

Thank you Lukas. I was able to get it resolved. There was a problem with the account that was set for us.

by (144k points)
edited

Thanks for letting us know!

0 votes
by (140 points)
edited

Hi Mali,

Do you know what the problem on the server was? I am using Jsch for sftp with key based authentication and I can send a few files successfully. But after some time the code breaks with Auth failure error ... Please let me know.

Thanks.

...