Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.7k views
in General by (200 points)
I am trying to setup sftp with third party ftp server, I have provided them my public key and they have registered on their server and I have written their public key in my knowhost file. Now I am trying to connect to ftp server through code :


_ftpConnection.ServerAddress = ServerAddress;
_ftpConnection.UserName = UserName;
_ftpConnection.Password = Password; //Passwordis blank as I am using Authentication type publickey
_ftpConnection.Protocol = FTPProtocol.SFTP;
_ftpConnection.AuthenticationMethod = AuthenticationType.PublicKey;
_ftpConnection.ClientPrivateKeyFile = pathToKey; //Path to my private key
_ftpConnection.ClientPrivateKeyPassphrase = passphrase; // pass phrase used to generate my private key
_ftpConnection.UseSFTPServerValidation = true;
_ftpConnection.KnownHosts.KnownHostFile = knownHostFilePath;
_ftpConnection.Connect();

It fails when it tries to connect and throw exception "AuthentiationFailed". Here's the attached trace below:

DEBUG [SSHFTPClient] 23 Jan 2014 12:44:11.323 : HostKeyChecker checking for ssh-
rsa public key of 'sft.XXXXYYYY.com'
DEBUG [ClientKeyExchanger] 23 Jan 2014 12:44:11.325 : Processed SSH_MSG_KEXDH_IN
IT reply successfully
DEBUG [ClientKeyExchanger] 23 Jan 2014 12:44:11.326 : Sending SSH_MSG_NEWKEYS
DEBUG [ClientKeyExchanger] 23 Jan 2014 12:44:11.327 : Sent SSH_MSG_NEWKEYS
DEBUG [ClientKeyExchanger] 23 Jan 2014 12:44:11.329 : Established ciphers
DEBUG [ClientKeyExchanger] 23 Jan 2014 12:44:11.330 : Established MACs
DEBUG [ClientKeyExchanger] 23 Jan 2014 12:44:11.330 : Reading SSH_MSG_NEWKEYS re
ply
DEBUG [AbstractKeyExchanger] 23 Jan 2014 12:44:11.331 : Processing SSH_MSG_NEWKE
YS reply
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.332 : Processed 0 queued messages
DEBUG [AbstractKeyExchanger] 23 Jan 2014 12:44:11.332 : Processed SSH_MSG_NEWKEY
S reply
INFO [AbstractKeyExchanger] 23 Jan 2014 12:44:11.332 : Negotiated new keys succe
ssfully
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.333 : Key exchange complete
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.336 : Sent SSH_MSG_SERVICE_REQUEST '
ssh-userauth'
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.336 : Waiting for packet
DEBUG [PlainSocket] 23 Jan 2014 12:44:11.391 : RepeatCallback received 52 bytes
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.392 : Packet arrived
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.394 : Starting user authentication
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.394 : Public key authentication
INFO [PuTTYPrivateKeyFormat] 23 Jan 2014 12:44:11.397 : Unpacking puTTY formatte
d private key
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.469 : Sent SSH_MSG_USERAUTH_REQUEST
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.471 : Waiting for packet
DEBUG [PlainSocket] 23 Jan 2014 12:44:11.570 : RepeatCallback received 76 bytes
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.571 : Packet arrived
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.572 : ProcessAuthenticationResponse:
SSH_MSG_USERAUTH_FAILURE
ERROR [SSH2Connection] 23 Jan 2014 12:44:11.572 : Auth failure. Try: password,publickey,keyboard-interactive
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.573 : Starting user authentication
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.573 : Password authentication
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.574 : Sent SSH_MSG_USERAUTH_REQUEST
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.574 : Waiting for packet
DEBUG [PlainSocket] 23 Jan 2014 12:44:11.600 : RepeatCallback received 76 bytes
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.601 : Packet arrived
DEBUG [SSH2Connection] 23 Jan 2014 12:44:11.601 : ProcessAuthenticationResponse:
SSH_MSG_USERAUTH_FAILURE
ERROR [SSH2Connection] 23 Jan 2014 12:44:11.602 : Auth failure. Try: password,pu
blickey,keyboard-interactive
ERROR [SSHFTPClient] 23 Jan 2014 12:44:11.608 : Failed to connect - closing conn
ection
ERROR [SSHFTPClient] 23 Jan 2014 12:44:11.608 : EnterpriseDT.Net.Ftp.Ssh.SFTPExc
eption: AuthenticationFailed
ERROR [SSHFTPClient] 23 Jan 2014 12:44:11.608 : at EnterpriseDT.Net.Ftp.Ssh.S
SHFTPClient.Connect()

5 Answers

0 votes
by (162k points)
Have you verified you can authenticate using your private key using another client like WinSCP?
0 votes
by (200 points)
I tried and got this error

[ img ]
0 votes
by (162k points)
You'll need to talk to the server administrator - I don't know what that error means.
0 votes
by (200 points)
Is this shows that the server doesn't have my public key registered.
Also I am not giving password while login into winscp. Only username and private key of mine.
0 votes
by (162k points)
Yes, it looks like your public key is not registered.

Categories

...