How to get ssh public key from private key in Linux

Suppose somehow you lost your ssh public key , you can use below command to regenerate it.

ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
  • -y : read a private OpenSSH format file and print an OpenSSH public key
  • -f : specify the filename of the key file

How to get ssh public key from private key in Windows

In windows you can use puttygen to generate public key from a private key file.


You need to name your private key file as a .ppk file , or you need to choose All Files : (*.*) when loading it