Sftp using ppk authentication

Jan 27, 2012 at 1:49 PM

Hy at all,  I'm looking a valid working c# example to upload files on remote server using ssh.net library, i need  doing SFTP with  publickey  authentication, could someone help me ?  thank you very much


Jan 27, 2012 at 3:40 PM

All you need to do is to use private key for authentication.

You can use this code to create connectionInfo object that can be used later for authentication.

            var connectionInfo = new PrivateKeyConnectionInfo("server", "username", new PrivateKeyFile(new MemoryStream(Encoding.ASCII.GetBytes(dsaKey))));

Where dsaKey is string that contain your private key.

You can also replace MemoryStream with FileStream, where it will read key information from the file.


Hope it helps,