Openssl Generate Private Public Key Pair Rating: 3,5/5 9797 reviews

To sign an assembly with a strong name, you must have a public/private key pair. This public and private cryptographic key pair is used during compilation to create a strong-named assembly. You can create a key pair using the Strong Name tool (Sn.exe). Key pair files usually have an.snk extension.

Lets say you have a private/public key pair that you use to login to your server via SSH and you lose the public key, either it was deleted or corrupt and you don’t want to have to regenerate a new pair what options do you have? In this post I will demonstrate how to regenerate a public key from the corresponding private key that you still have.

  • The private key is generated and saved in a file named 'rsa.private' located in the same folder. Generating the Public Key - Linux 1. Open the Terminal. Type the following: openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM 2. The public key is saved in a file named rsa.public located in the same folder.
  • Generating Public and Private Keys with openssl.exe To perform the following actions for Windows or Linux, you must have OpenSSL installed on your system. Generating the Private Key - Windows In Windows: 1. Open the Command Prompt (Start Programs Accessories Command Prompt). Navigate to the following folder.
  • To sign an assembly with a strong name, you must have a public/private key pair. This public and private cryptographic key pair is used during compilation to create a strong-named assembly. You can create a key pair using the Strong Name tool (Sn.exe). Key pair files usually have an.snk extension.

Generate public key and store into a file

It is a simple one liner command to generate a public key from a private key, so lets say our private key is named ‘user@myserver.key’ and we want to generate the public key and name it ‘authorized_keys’. Below is the command to do this.

2
4
6
user@workstation:~$rsync-avz--remove-source-files authorized_keys user@remote_server_ip_address:/home/user/.ssh/authorized_keys
test
sent95bytes received43bytes92.00bytes/sec
user@workstation:~$

At this point our public key file is on our server where it is supposed to be in our users ‘.ssh’ directory.

Set proper permissions for public key

Lastly we will need to make sure our permissions are set properly on our public key to prevent anyone else tampering with it. We should give our key file RW, R, R permissions, below is the command to properly set permission on the key.