up vote 30 down vote favorite
5
share [g+] share [fb]

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?

link|improve this question

79% accept rate
feedback

1 Answer

up vote 35 down vote accepted

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.

link|improve this answer
4  
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
1  
Good point, updated accordingly – Kyle Brandt Aug 10 '09 at 14:52
yeah mine originally was RSA. – Rory McCann Aug 10 '09 at 15:19
feedback

Your Answer

 
or
required, but never shown

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