SshNet.PuttyKeyFile
SSH.NET Extension to read and use Authentication Keys in PuTTY-Format
Status
WIP
Supports PPK v2 and v3
.NET Frameworks
- .NET 4.0
- .NET 4.6.2
- netstandard 2.0
.NET 4.0 Note
PPK v3 encryption is not supported on .NET 4.0
Keys
- ssh-ed25519
- ecdsa-sha2-nistp256
- ecdsa-sha2-nistp384
- ecdsa-sha2-nistp521
- ssh-rsa with 2048, 3072, 4096 or 8192 KeyLength
Key Encryption
- None
- AES256-cbc
Usage Example
var key = new PuttyKeyFile("my-key.ppk");
using var client = new SshClient("ssh.foo.com", "root", key);
client.Connect();
Console.WriteLine(client.RunCommand("hostname").Result);
Automatically load the key based on file contents
using Renci.SshNet;
using SshNet.PuttyKeyFile;
var keyText = "<ssh key contents>";
IPrivateKeySource key = PuttyKeyFile.IsPuttyPrivateKey(keyText) ? new PuttyKeyFile(keyText) : new PrivateKeyFile(keyText);
// or with passPhrase
var passPhrase = "<ssh key password/passphrase>";
IPrivateKeySource key = PuttyKeyFile.IsPuttyPrivateKey(keyText) ? new PuttyKeyFile(keyText, passPhrase) : new PrivateKeyFile(keyText, passPhrase);
using var client = new SshClient("ssh.foo.com", "root", key);
client.Connect();
Console.WriteLine(client.RunCommand("hostname").Result);