Generating SSH keys and adding them to GitHub

In order to work with a Github account remotely, you must prove ownership of the account. This is done with SSH keys. This cheat sheet describes how to generate public/private keys on the linux command line and set the public key to a Github account.

Generate a local SSH pair of keys using the following command

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

The SSH key pair is generated as two files: secret and public. The file can also be named. Set an optional passphrase or skip it by hitting enter twice. Using a password is more than recommended on a shared machine.

~/.ssh/id_rsa
~/.ssh/id_rsa.pub

Copy only the public key

cat .ssh/id_rsa.pub

To add it to a Github account. Go on "Settings" in your profile and click on "SSH and GPG keys" from the side menu.

Finally, set the directory and file permissions on the local machine

chmod 700 .ssh
chmod 600 .ssh/id_rsa
chmod 644 .ssh/id_rsa.pub

List public and private keys

ls -l ~/.ssh/