So, you’ve lost your public key but still have your private key. Or, maybe, you’ve downloaded the private key portion of the SSH key-pair that AWS (Amazon Web Services) generated and now you need the public portion (because AWS doesn’t give that to you for some reason).
It’s actually quite easy to get the public key out of the private key file. As long as you have access to ssh-keygen (which most modern linux distributions include.)
So, here’s how you extract your SSH Public Key:
- Upload your private key file to a Linux server.
- Change the permissions on the file to 600:
sudo chmod 600 yourfilename
You need to change the permissions otherwise ssh-keygen will refuse to handle the file.
- Run the following command:
sudo ssh-keygen -y -f yourfilename
That should echo out the public key. Copy and paste it to a new file and you’re good to go!
Was This Article Useful? Or do you have questions or comments about it (or our products & services)? We'd love to hear from you!
Automatic Notification Of New Articles
Sign up to get automatic notifications of new articles. This is a different list than our standard list - you only get new articles once a week (usually on Mondays). No other emails will be sent unless you sign up for our general list as well.
Follow us on Twitter! We post a lot of cool things there first. To keep up, click the "X" below!