Create a public SSH key from the private key?

Solution 1:

Use the -y option to ssh-keygen:

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

From the 'man ssh-keygen'

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

Specify the private key with the -f option, yours might be dsa instead of rsa. The name of your private key probably contains which you used. The newly generated public key should be the same as the one you generated before.

Solution 2:

Solution is specifically for users using Windows

Tool Used:

  • Puttygen (PuTTY Key Generator)
  • WinSCP

Steps to perform:

  1. Open PuTTY Key Generator.
  2. Load your private key (*.ppk file).
  3. Copy your public key data from the "Public key for pasting into OpenSSH authorized_keys file" section of the PuTTY Key Generator and paste the key data to the "authorized_keys" file (using notepad) if you want to use it.

Snapshot showing portions of Puttygen to focus:

Snapshot showing portions of Puttygen to focus