Restore SSH Public Key
Today I did something stupid: I overwrote an SSH public key with a file from a different machine:
scp id_rsa.pub user@example.org:~/.ssh
Obviously, I wanted to place the Public Key for the account from one machine on the other one to append it to the authorized_keys file of the target account. Unfortunately, I didn’t bear in mind that I already had a public key file (id_rsa.pub) in this directory. So I had to re-create the Public Key file from the Private Key. This is quite easy, it appears that the SSH developers already thought of this situation. The following code will restore the Public Key file from the Private Key (example for an RSA key):
cd ~/.ssh; echo "id_rsa" | ssh-keygen -y > id_rsa.pub 2>/dev/null


Recent Links Tagged With "publickey" - JabberTags · October 11th, 2008 at 11:49 pm #
[...] public links >> publickey Restore SSH Public Key Saved by mgalindo on Fri 10-10-2008 Advanced SSH security tips and tricks Saved by lax on Fri [...]
jdebaer · October 5th, 2010 at 1:08 pm #
thanks for this – today I did something stupid too
M. hossam · March 11th, 2011 at 3:44 pm #
is that possible to reverse the matter
as i did a very stupid thing tooooo
but by deleting the id_rsa
prviate key
any way to restre it
thanks
Alex · March 13th, 2011 at 1:43 pm #
Of course not. What would be the point of asymetric cryptography, if you could create the private key from the public one?