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.
Generate public key and store into a file
Oct 20, 2014 The utility will prompt you to select a location for the keys that will be generated. By default, the keys will be stored in the /.ssh directory within your userâs home directory. The private key will be called idrsa and the associated public key will be called idrsa.pub.
It is a simple one liner command to generate a public key from a private key, so lets say our private key is named â[email protected]â and we want to generate the public key and name it âauthorized_keysâ. Below is the command to do this.
Command Breakdown:
Nba 2k14 nba 2k14 cd key generator. This is the main device that produces just unique and legitimate keys that you can utilize. Our NBA 2K14 serial keygen is the main apparatus on web right now that works and is as a rule always refreshed by our group at gamecrackz.org. So download our most recent adaptation of NBA 2K14 cd key generator device and begin playing it today.
Key features of second generation computers images. âssh-keygen -yâ : tells the prorgram ssh-keygen to output a public key
â-f [email protected]â: references the key file [email protected] to generate the public key from
â> authorized_keysâ: instead of printing the output to the console redirect the output (public key) to a file named âauthorized_keysâ
Copy public key to your server
Now we will need to take our authorized_keys file and store it on the server, if we can currently login via SSH to our server we can use rsync over ssh to securely copy the public key to the server, Although this key is displayed to anyone who attempts to login to your server it is smart to use SSH or another secure method to copy it up to the server to ensure that the key is not tampered with while it is being transmitted.
Below is an example using rsync to copy the authorized keys file to its destination on the server and removing it from your local computer.
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.
How To Generate Ssh Keys
eg:
Take note of the output, and copy it into the clipboard if possible, or use some other method to get this file/data onto the remote machine, as it will be used in the next step.
On the remote server you want to be able to log into:
If you have chosen to copy the public key file to the remote host instead, you can issue the following command instead:
Logging into remote ssh server using the private key file
To connect to the remote host using SSH you can use the following command:
This will use the private key called âkeypairâ created earlier, and assuming the remote server has the public key added to the âuserâ users authorized_keys file, you should be able to log into the remote system.
Increase PHP Upload Limit on Ubuntu 12.04January 15, 2013Generate Private Key Ssh Linux 10adding persistent static routes on centosJune 6, 2017Comments are closed.
|