madmik3 madmik3 - 1 month ago 25
C# Question

Sftp from SharpSSH and public key

I am using SharpSSH's Sftp class to upload files. Someone has requested that I enable RSA authentication. I can't find an info how how to do this. What do I need to do in order to support public key authentication in SharpSSH?

All I currently do is this

ftp = new Sftp(config.SftpServer, config.SftpUsername, config.SftpPassowrd);
ftp.Connect();

Answer

In order to connect with an RSA I needed to create an OpenSSH format key and save it to disk. PuttyGen worked well for this. Then I simply needed to call AddIdentityFile with that file like so

 ftp = new Sftp(config.SftpServer, config.SftpUsername, config.SftpPassowrd);
 ftp.AddIdentityFile("file");
 ftp.Connect();