Are you targeting .NET Compact Framework? SshPrivateKey.Generate
is not available on that platform because - historically - key generation on Windows CE devices was very slow.
However, you can still generate SshPrivateKey
keys on .NET CF indirectly via AsymmetricKeyAlgorithm
class:
var alg = new AsymmetricKeyAlgorithm();
alg.GenerateKey(AsymmetricKeyAlgorithmId.RSA, 2048);
byte[] keyData = alg.GetPrivateKey().ToBytes();
var key = new SshPrivateKey(keyData);
Sorry for inconvenience. We'll enable SshPrivateKey.Generate
on .NET CF as well and let the users decide whether it's fast enough for their needs.