Blog
How to generate a secure SSH key pair
I make a new SSH key for every new account or server, and this is the note I come back to each time.
Generate an SSH key pair
- Open your favorite terminal
- Run the ssh-keygen command
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
For a strong key, use the type flag
-t rsawith the bits flag-b 4096. The comment flag-C "[email protected]"labels the key, so you can later tell who owns it.
- Specify the key file name. The default is
id_rsa - Enter a passphrase (optional, but a good idea)

Warning: if you already have a default key at
~/.ssh/id_rsa, do not overwrite it. You would lose SSH access to every server and Git platform that uses it. Give the new key its own name instead, such asid_rsa_avengers.