Authentication into SFTP server using PrivateKey - WeOnlyDo Discussion board

Authentication into SFTP server using PrivateKey (wodFtpDLX / wodFtpDLX.NET)

by jxt, Wednesday, April 01, 2015, 22:02 (3524 days ago)

Hello,

I am having a hard time supplying the Private Key via code, to authenticate into an SFTP server.

Here's my code -



WeOnlyDo.Client.FtpDLX ftp = new FtpDLX();

ftp.Hostname = "xxxxx";
ftp.Protocol = Protocols.SFTP;
ftp.Port = 22;

ftp.Login = "xxxxx";
ftp.Authentication = Authentications.PublicKey;
ftp.PrivateKey = "-----BEGIN RSA PRIVATE KEY-----MIIE.. ..Q1YSo=-----END RSA PRIVATE KEY-----";

ftp.Blocking = true;
ftp.Timeout = 10;

ftp.Connect();

I generated a SSH-2 RSA Public/Private key pair using puTTYgen and subsequently converted the Private Key to OpenSSH format and saved it to a file. How do I supply this Private key into the "PrivateKey" property? When I try to use the contents of the Private Key file as is - pasted as one long string -, I get the error "Failed to import Private Key".

Your help is much appreciated.


Complete thread: