SSH Key Cheatsheet
As with all cheatsheets, this will be added to over time.
~/.ssh/id_rsa
if you are concerned with just your own computers key rather than a key file.
Create Key
ssh-keygen
Add Passphrase
If you were given an unencrypted SSH key, such as from AWS, then you probably want to add a passphrase to it with the following command:
ssh-keygen -p -f my-private-key.pem
Remove Passphrase
Just do the same again as adding passphrase, this time enter the current passphrase and then don't enter anything for the new one.
ssh-keygen -p -f my-private-key.pem
Generate public key from private key
ssh-keygen -f [key path] -y > [key path].pub
Add Key To Remote Server
Refer here if you wish to see how to easily add this key to a remote server so that you can use it to log in.
Convert RSA PEM Key To OpenSSH Format
The following command will convert the PEM key file in place to the OpenSSH format, so be sure to make a copy if you want to keep the original format too.
ssh-keygen -p -N "" -f /path/to/key
References
- ServerFault - Create a public SSH key from the private key?
- Unix & Linux - How can I determine if someone's SSH key contains an empty passphrase?
- Remove passphrase (password) from private RSA key
- Stack Overflow - How do I add a password to an OpenSSH private key that was generated without a password?
- Stack Overflow - Convert RSA to OPENSSH
Last updated: 25th November 2021
First published: 16th August 2018
First published: 16th August 2018