How to create public key from SSH private key?

Lost SSH public key, don’t worry, you can generate it from your private key file. If you have an SSH private key, you can generate the public key using the ssh-keygen command.

ssh-keygen -f PRIVATE_KEY_HERE -y

-y option will read a private OpenSSH format file and print an OpenSSH public key to stdout.
-f specifies the location of your private key file.

Example

ssh-keygen generate public key

If you have passphrase set, ssh-keygen will prompt for the password.

root@ee:~/my-key# ssh-keygen -f boby.pem -y
Enter passphrase: 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAEF0dvZOurGujYDucipjXjM2mHE+BFO91HGZKRU/RkpS1ZDzQiA164yev9eoxZRTHHnxb46TWfoLeHy8nEwa+BkijxBnaCkU2GlC9oFInSnCHLUuas87c/EBJ4KTcjfoZ+Ocxjn0MP0T4YsSzwIU1v8deH7t7/zQJW733DyVls0wDlRTgHGzlldBnrzF9dSNMRMXQuhl+rcQtIapfrjVPZGlkQfh7yCUJf2oK10l9I01zrITdwlzqao1732AtdXt6GlHz6016mWfzjLGX/RGnkj1+5XEYYa9IIQRN7IXhNwcgzDybI0OLsioeKapSprWhs9Ftx14csyC/7PXHuf+50vDOs26NM3BsFuwUB6R0Tkm88uJeDj/HAwlDlowFk8GIYU4WIZr85g1TUeV0eXwjFc3wEgLBO7b6VbBXDRpnhOec8Lnmpj1BUK4Bp4z27PuxhGj5CUnc096ZDOit3EzOeOfAzanFrtlT+td/GmS0GJ0hhBs+6u9aLdiKE28Oies= root@ee
root@ee:~/my-key# 

See SSH, ssh-keygen

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *