Today I needed to generate a new public key from a private key that I had in order to setup key based authentication for one of my web servers. Since, I don't have a post that is about this I decided to create one now.
As long as you have a private key which if you look at the contents of the file will have the following lines in it minus the '/--Redacted--/'.
----BEGIN OPENSSH PRIVATE KEY---—
-----END OPENSSH PRIVATE KEY--—
Once you verify the file you can use the following command in the terminal to create your new public key.
ssh-keygen -yf ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
Once that command is run you can verify the file by looking at the contents and seeing
ssh-rsa as the first part of the key. You should be able to upload the public key to your remote server and then try to authenticate with your private key.
ssh -i ~/.ssh/id_rsa USERNAME@ADDRESS
As always, if you have questions or feedback about anything I say please email me.