Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's suppose I have a SSH key, but I've deleted the public key part. I have the private key part. Is there some way I can regenerate the public key part?

share|improve this question
up vote 165 down vote accepted

Use the -y option to ssh-keygen:

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

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.

share|improve this answer
Why the "-t dsa"? Mayge the OP's key is rsa? I'd get rid of -t and instead use a -f. – innaM Aug 10 '09 at 14:44
Good point, updated accordingly – Kyle Brandt Aug 10 '09 at 14:52
yeah mine originally was RSA. – Rory Aug 10 '09 at 15:19
On Mac OSX 10.9.3 Mavericks I'm getting 'load failed' after running the command. How do I solve this? – Hyperfocus Jun 8 '14 at 18:02
I think you might take this one step further with the -N parameter in case the private key is password protected: ssh-keygen -f ~/.ssh/id_rsa -y -N "$PASSWORD" > ~/.ssh/ – ken Oct 7 '14 at 12:28

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

share|improve this answer
Further reading:… – devprashant Nov 21 '15 at 10:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.