I'm having some difficulty connecting to an SFTP site using EnterpriseDT. I've been using edt inside of my file mover project for a few years, and haven't had any problems connecting to FTP, FTPS, or SFTP using a username and password. However, my newest requirement is to connect to an SFTP server using public key authentication. I haven't seen much out there in the web about this, but I've implemented what I have seen. However, I am unable to authenticate using this software. I have successfully connected using FileZilla alongside of Pageant, so I know that the server is ok.
To generate a key, I used PuTTY, and generated a SSH-2 DSA public and private key.
I've tried setting the PreferredCipherAlgorithms and PreferredHostKeyAlgorithms to all the possible combinations, with no luck. I've also tried modifying the private key file in various ways (removing the comments, removing the public key, removing the private key, removing the whitespace, etc.) just on the off chance that had anything to do with it.
I'm using edtFTPnetPRO, file version 4.1.2.0, on .NET 2.0 on Windows XP Professional.
Below is my code, followed by the exception that is raised on the Connect() method, followed by the log4net output of the process. I would greatly appreciate any insight anyone has.
Thank you very much.
Joe Enos
using (SecureFTPConnection ftp = new SecureFTPConnection())
{
ftp.ServerPort = 21;
ftp.ServerAddress = GetFTPAddress;
ftp.Protocol = FileTransferProtocol.SFTP;
ftp.UserName = GetFTPUserName;
ftp.Password = string.Empty; // If I leave this out, I get an InvalidOperationException that "Password property is not set".
ftp.AuthenticationMethod = AuthenticationType.PublicKey;
ftp.ClientPrivateKeyFile = PrivateKeyFile; // c:\temp\myfile.ppk
ftp.ServerValidation = SecureFTPServerValidationType.None;
SetFtpConnectMode(ftp);
ftp.EventsEnabled = true;
ftp.Downloaded += ftp_Downloaded;
ftp.Connect();
}
EnterpriseDT.Net.Ftp.Ssh.SFTPException: Failed to recognize key format
at f3.a(Byte[] A_0)
at f3.a(Byte[] A_0, String A_1)
at f3.a(String A_0, String A_1)
at aw.a(String A_0, String A_1)
at hf.e()
at hf.a(a2 A_0)
at a7.a(ai A_0, b7 A_1, gw A_2, a2 A_3)
at a7.a(ai A_0, b7 A_1, Socket A_2)
at EnterpriseDT.Net.Ftp.Ssh.SSHFTPClient.Connect()
at EnterpriseDT.Net.Ftp.SecureFTPConnection.Connect()
at InterfaceProcessingAgentWorker.FileMonitorWorker.GetRemoteSecureFiles(String tempLocation)
DEBUG [SSHFTPClient] 6 Mar 2009 09:20:30.466 : Connecting directly to SFTP server 999.999.999.999:22
DEBUG [SSHFTPClient] 6 Mar 2009 09:20:30.545 : Connected successfully to SFTP server 999.999.999.999:22
DEBUG [SSHConnection] 6 Mar 2009 09:20:30.545 : Beginning protocol negotiation
DEBUG [SSHConnection] 6 Mar 2009 09:20:30.545 : Protocol negotiation complete
DEBUG [PlainSocket] 6 Mar 2009 09:20:30.701 : RepeatCallback received 20 bytes
DEBUG [ProtocolNegotiationHandler] 6 Mar 2009 09:20:30.701 : offset=0,length=20
DEBUG [ProtocolNegotiationHandler] 6 Mar 2009 09:20:30.701 : pos=19
DEBUG [SSHConnection] 6 Mar 2009 09:20:30.701 : Server version=SSH-2.0-OpenSSH_4.7
DEBUG [SSH2Connection] 6 Mar 2009 09:20:30.701 : Timeout=120000
DEBUG [SSHConnection] 6 Mar 2009 09:20:30.701 : Sending client version=SSH-2.0-edtFTPnet/PRO-4.1.2.0
DEBUG [SSH2Connection] 6 Mar 2009 09:20:30.701 : Starting key exchange
DEBUG [KeyExchanger] 6 Mar 2009 09:20:30.701 : Sending SSH_MSG_KEXINIT
DEBUG [KeyExchanger] 6 Mar 2009 09:20:30.701 : Client hostkey algorithms=ssh-dss
DEBUG [KeyExchanger] 6 Mar 2009 09:20:30.701 : Client ciphers=aes128-cbc,blowfish-cbc,3des-cbc
DEBUG [KeyExchanger] 6 Mar 2009 09:20:30.701 : Client ciphers=aes128-cbc,blowfish-cbc,3des-cbc
DEBUG [KeyExchanger] 6 Mar 2009 09:20:30.701 : Client compression algorithms=none,zlib
DEBUG [KeyExchanger] 6 Mar 2009 09:20:30.701 : Client compression algorithms=none,zlib
DEBUG [KeyExchanger] 6 Mar 2009 09:20:30.701 : Sent SSH_MSG_KEXINIT
DEBUG [KeyExchanger] 6 Mar 2009 09:20:30.701 : Reading SSH_MSG_KEXINIT reply
DEBUG [SSH2Connection] 6 Mar 2009 09:20:30.701 : Waiting for packet
DEBUG [PlainSocket] 6 Mar 2009 09:20:34.982 : RepeatCallback received 784 bytes
DEBUG [SSH2Connection] 6 Mar 2009 09:20:34.982 : Packet arrived
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Processing SSH_MSG_KEXINIT reply
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Kex alg=diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Hostkey alg=ssh-rsa,ssh-dss
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Cipher CS=aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Cipher SC=aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : MAC CS=hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : MAC SC=hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Comp CS=none,zlib@openssh.com
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Comp SC=none,zlib@openssh.com
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Processed SSH_MSG_KEXINIT reply
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.982 : Sending SSH_MSG_KEXDH_INIT
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.998 : Sent SSH_MSG_KEXDH_INIT
DEBUG [KeyExchanger] 6 Mar 2009 09:20:34.998 : Reading SSH_MSG_KEXDH_INIT reply
DEBUG [SSH2Connection] 6 Mar 2009 09:20:34.998 : Waiting for packet
DEBUG [PlainSocket] 6 Mar 2009 09:20:35.232 : RepeatCallback received 1040 bytes
DEBUG [SSH2Connection] 6 Mar 2009 09:20:35.232 : Packet arrived
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.232 : Processing SSH_MSG_KEXDH_INIT reply
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.310 : Processed SSH_MSG_KEXDH_INIT reply successfully
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.310 : Sending SSH_MSG_NEWKEYS
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.310 : Sent SSH_MSG_NEWKEYS
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.310 : Established ciphers
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.310 : Established MACs
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.310 : Reading SSH_MSG_NEWKEYS reply
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.310 : Processing SSH_MSG_NEWKEYS reply
DEBUG [KeyExchanger] 6 Mar 2009 09:20:35.310 : Processed SSH_MSG_NEWKEYS reply
DEBUG [SSH2Connection] 6 Mar 2009 09:20:35.310 : Key exchange complete
DEBUG [SSH2Connection] 6 Mar 2009 09:20:35.310 : Waiting for packet
DEBUG [PlainSocket] 6 Mar 2009 09:20:35.576 : RepeatCallback received 52 bytes
DEBUG [SSH2Connection] 6 Mar 2009 09:20:35.576 : Packet arrived
DEBUG [SSH2Connection] 6 Mar 2009 09:20:35.576 : Starting user authentication
DEBUG [SSH2Connection] 6 Mar 2009 09:20:35.576 : Public key authentication
ERROR [PrivateKeyFactory] 6 Mar 2009 09:20:35.591 : Failed to recognize key format