SshKeyGenerator 1.1.18

A native .NET and .NET Core library for creating SSH RSA keys suitable for use with SSH clients and Git+SSH authentication

There is a newer version of this package available.
See the version list below for details.
Install-Package SshKeyGenerator -Version 1.1.18
dotnet add package SshKeyGenerator --version 1.1.18
<PackageReference Include="SshKeyGenerator" Version="1.1.18" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SshKeyGenerator --version 1.1.18
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

DotNet Core SSH KeyGen

Build status

After searching around for a solution to creating SSH keys using C# and dotnet core I came across the following stackoverflow posts which explain how to convert from RSACryptoServiceProvider to values suitable for use with ssh.

Supported Platforms

  • .NET 4.5 (Desktop / Server)
  • .NET Standard 2.0

Installation

SshKeyGenerator is a library for .NET and is available on NuGet:

Install-Package SshKeyGenerator

or

dotnet add package SshKeyGenerator

Usage Example

var keygen = new SshKeyGenerator(2048);

var privateKey = keygen.ToPrivateKey();
Console.WriteLine(privateKey);

var publicSshKey = keygen.ToRfcPublicKey();
Console.WriteLine(publicSshKey);

var publicSshKeyWithComment = keygen.ToRfcPublicKey("user@domain.com");
Console.WriteLine(publicSshKeyWithComment);

Sample Output

keygen.ToPrivateKey()
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAs1O/9F2XlZVaVWEUYfflxx0wDG9FE09hQF2wngA6EemHpe6I
hvdwvQ7obrZ85jSYdBxBRjNAYF3T9+wU+8w6m4qZCVYvqqRjszN8j3VwUBLzWilt
...
wDGzJIkmbhANi+252pH6PAuWjZPfz8COGA6QPPH0/khpHPj1LY4mi5Ubi3YT1uRo
dOGttjtkj9fLX5IQ81G9HR0MdT1Gd4fPenYPOUCgCPB5adpT1BB+
-----END RSA PRIVATE KEY-----
keygen.ToRfcPublicKey()
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzU7/0XZeVlVpVYRRh9
...
+ohFsbcbAMcfLWGUdouyHvLvF21G0z50z2i2CrU7WW4WdrGGfxhU3TeRTXd7Skwk/K7iBBn3oc/xct generated-key
keygen.ToRfcPublicKey("user@domain.com")
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzU7/0XZeVlVpVYRRh9
...
+ohFsbcbAMcfLWGUdouyHvLvF21G0z50z2i2CrU7WW4WdrGGfxhU3TeRTXd7Skwk/K7iBBn3oc/xct user@domain.com

References

  • Exporting Private Key: https://stackoverflow.com/a/23739932
  • Exporting Public Key: https://stackoverflow.com/a/25591659
  • Exporting Public Key in RFC4716 Format: https://stackoverflow.com/a/47917364

Contributors

Thanks to the following contributors for their assistance with this library.

DotNet Core SSH KeyGen

Build status

After searching around for a solution to creating SSH keys using C# and dotnet core I came across the following stackoverflow posts which explain how to convert from RSACryptoServiceProvider to values suitable for use with ssh.

Supported Platforms

  • .NET 4.5 (Desktop / Server)
  • .NET Standard 2.0

Installation

SshKeyGenerator is a library for .NET and is available on NuGet:

Install-Package SshKeyGenerator

or

dotnet add package SshKeyGenerator

Usage Example

var keygen = new SshKeyGenerator(2048);

var privateKey = keygen.ToPrivateKey();
Console.WriteLine(privateKey);

var publicSshKey = keygen.ToRfcPublicKey();
Console.WriteLine(publicSshKey);

var publicSshKeyWithComment = keygen.ToRfcPublicKey("user@domain.com");
Console.WriteLine(publicSshKeyWithComment);

Sample Output

keygen.ToPrivateKey()
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAs1O/9F2XlZVaVWEUYfflxx0wDG9FE09hQF2wngA6EemHpe6I
hvdwvQ7obrZ85jSYdBxBRjNAYF3T9+wU+8w6m4qZCVYvqqRjszN8j3VwUBLzWilt
...
wDGzJIkmbhANi+252pH6PAuWjZPfz8COGA6QPPH0/khpHPj1LY4mi5Ubi3YT1uRo
dOGttjtkj9fLX5IQ81G9HR0MdT1Gd4fPenYPOUCgCPB5adpT1BB+
-----END RSA PRIVATE KEY-----
keygen.ToRfcPublicKey()
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzU7/0XZeVlVpVYRRh9
...
+ohFsbcbAMcfLWGUdouyHvLvF21G0z50z2i2CrU7WW4WdrGGfxhU3TeRTXd7Skwk/K7iBBn3oc/xct generated-key
keygen.ToRfcPublicKey("user@domain.com")
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzU7/0XZeVlVpVYRRh9
...
+ohFsbcbAMcfLWGUdouyHvLvF21G0z50z2i2CrU7WW4WdrGGfxhU3TeRTXd7Skwk/K7iBBn3oc/xct user@domain.com

References

  • Exporting Private Key: https://stackoverflow.com/a/23739932
  • Exporting Public Key: https://stackoverflow.com/a/25591659
  • Exporting Public Key in RFC4716 Format: https://stackoverflow.com/a/47917364

Contributors

Thanks to the following contributors for their assistance with this library.

  • .NETFramework 4.5.2

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.1.33 4,347 3/5/2020
1.1.32 86 3/5/2020
1.1.31 3,058 10/30/2019
1.1.19 2,247 7/21/2018
1.1.18 282 7/21/2018
1.1.17 250 7/21/2018
1.1.16 324 7/18/2018
1.1.15 326 7/18/2018
1.1.14 323 7/18/2018
1.1.13 316 7/17/2018
1.1.12 316 7/17/2018
1.1.11 6,100 7/17/2018