Friday, August 3, 2012

Create ssh public key from private key

If you have a private key and want to create the public key from that (to put in ~/.ssh/authorized_keys, for example), do the following:

ssh-keygen -f <my_private_key> -y > <my_public_key>

For example:

ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub


If you are using this to ssh with keys, add my_public_key (eg. ~/.ssh/id_rsa.pub) to ~/.ssh/authorized_keys on the remote server.

Then ssh with the private key to the remote server to test.


No comments: