Archived Forum Post

Index of archived forum posts

Question:

SFTP Key Authentication functioning when initiated from one machine but not another

Sep 16 '15 at 21:50

We are having an issue where we cannot properly authenticate to a remote SFTP server via public key (sftp.AuthenticatePk) on one of our machines, however when we initiate the same connection from either our test bed or another machine, everything connects perfectly.

On the functioning machine and test environments AuthenticatePK returns true and we can interact with the sftp server as normal, however on the unsuccessful machine AuthenticatePK returns false. Both are running identical code and loading the same private key file. On the unsuccessful machine the AuthFailReason returns as 0 after receiving false from Authenticate PK.

Here is the LastErrorText from the failing machine, I've erased the UnlockPrefix, Username and login, but can provide those if needed:

ChilkatLog:
  AuthenticatePk:
    DllDate: Aug 26 2015
    ChilkatVersion: 9.5.0.52
    UnlockPrefix: XXX
    Username: XXX
    Architecture: Little Endian; 32-bit
    Language: .NET 4.0
    VerboseLogging: 0
    SshVersion: SSH-2.0-9.99 sshlib: 8.0.0.2
    SftpVersion: 0
    login: XXX
    sshAuthenticatePk:
      requestUserAuthService:
        sendServiceRequest:
          svcName: ssh-userauth
          SentServiceReq: ssh-userauth
        --sendServiceRequest
        sshReadMessage:
          mType: SERVICE_ACCEPT
        --sshReadMessage
        ssh-userauth service accepted.
      --requestUserAuthService
      Using an RSA key.
      publicKeyBlobSize: 279
      msgPayloadSize: 351
      Sent public-key request.
      sshReadMessage:
        mType: USERAUTH_PK_OK
      --sshReadMessage
      OK to proceed with publickey authentication.
      rsaSigLen: 256
      Sent public-key request with signature.
      sshReadMessage:
        mType: USERAUTH_FAILURE
      --sshReadMessage
      Authentication failed or partial success. (4)
      PartialSuccess4: 0
      AuthList: publickey,password
      Publickey authentication failed..
    --sshAuthenticatePk
    Failed.
  --AuthenticatePk
--ChilkatLog

Here is the LastErrorText from a working machine:

ChilkatLog:
  AuthenticatePk:
    DllDate: Aug 26 2015
    ChilkatVersion: 9.5.0.52
    UnlockPrefix: XXX
    Username: XXX
    Architecture: Little Endian; 32-bit
    Language: .NET 4.0
    VerboseLogging: 0
    SshVersion: SSH-2.0-9.99 sshlib: 8.0.0.2
    SftpVersion: 0
    login: XXX
    sshAuthenticatePk:
      requestUserAuthService:
        sendServiceRequest:
          svcName: ssh-userauth
          SentServiceReq: ssh-userauth
        --sendServiceRequest
        sshReadMessage:
          mType: SERVICE_ACCEPT
        --sshReadMessage
        ssh-userauth service accepted.
      --requestUserAuthService
      Using an RSA key.
      publicKeyBlobSize: 279
      msgPayloadSize: 351
      Sent public-key request.
      sshReadMessage:
        mType: USERAUTH_PK_OK
      --sshReadMessage
      OK to proceed with publickey authentication.
      rsaSigLen: 256
      Sent public-key request with signature.
      sshReadMessage:
        mType: USERAUTH_SUCCESS
      --sshReadMessage
      Public-key authentication succeeded.
    --sshAuthenticatePk
    Success.
  --AuthenticatePk
--ChilkatLog

Is there any way to get more information on what may be causing the server to reject the authentication from one machine but not another?


Answer

The public key part of your private key should be installed on the SSH server for the given user account. The most likely cause of the problem is that the public key was installed under the wrong user account, or the wrong public key was installed on the SSH server under the correct user account.