How to generate an SSH key pair in Mac OS?

You can generate a key in Mac OS using the ssh-keygen command. You should run it in Terminal or iTerm and specify a type of encryption. You will also be asked for a file in which the key should be saved to and for a passphrase (password) for the key:

This will create a private key written to ~/id_rsa and a public key written to ~/ The passphrase is used to protect your key. You will be asked for it when you load your key. You can load the key using the following command:

ssh-add ~/id_rsa