I recently came across this situation by which the public SSH key of a server is lost and I was instructed to add the public key to other server’s authorized_hosts file to enable password less SSH authentication. However I was not allowed to create a new keypair as the old key could be in place in multiple places. This ssh-keygen command was a lifesaver.
This command will recover the public key if you have the private key with you.
ssh-keygen -y -f id_rsa_private_key_file > publickey.pub
Please let me know via comments if you are having trouble with this command.
Last Modified: