Retrieve Public Key from Private Key

Retrieve Public Key from Private Key

Losing a public key can be a problem if you want to change the key pair by generating it again.

However, ssh-keygen can help you retrieve the public from the private key itself.

Retrieve Public Key from Private Key

By using ssh-keygen, you can retrieve public key from private key that you have.

The following is the syntax:

ssh-keygen -y -f /PATH/TO/PRIVATE/KEY

Where,

-y - Will read a private OpenSSH format file and print an OpenSSH public key to stdout.

Let’s put this in some example. I will try to retrieve public from the private key I have ~/.ssh/id_rsa

[[email protected] ~]# ssh-keygen -y -f ~/.ssh/id_rsa

This will provide the contents of the public key. You can put this output in another file in order to avoid any bad characters during the copy/paste action.

[[email protected] ~]# ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub

That should provide you the public key for the private key you have with you.

Retrieve Public Key from Private Key

No Comments

Post a Comment

Time limit is exhausted. Please reload CAPTCHA.