Generating SSH keys and adding 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 ""

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.


Copy only the public key

cat .ssh/

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/

List public and private keys

ls -l ~/.ssh/

// viHannes, 30 Jul 2022 in Helsinki, Finland