0 votes
by (140 points)

1 Answer

0 votes
by (148k points)

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.

by (140 points)
Thanks, suggested alternative method  also will help me
by (148k points)
We enabled SshPrivateKey.Generate methods on .NET CF in version 2019 R3:
https://www.rebex.net/total-pack/history.aspx#2019R3
...