In order to exchange data with GitHub, you will need to prove that you are the owner of an account.
In this example, I will explain how to do this using SSH keys, this can be used to connect a local machine or server to GitHub.
- Generate an SSH keygen on the terminal by running the following command:
ssh-keygen -t rsa -b 4096 -C “my-github-email-address@mail-service.com”
Make sure you use the email associated with your GitHub account. - Running the above command will promt you to enter the name that will be used for the SSH keys. Note that by default the keys will be stored in the .ssh folder in your home directory. Press ENTER to use this default naming convention or key the name you would like to use and then press ENTER.
- You will now be promted to enter a passphrase. Click ENTER to not set a passphrase, or key in the passphrase you would like to use and press ENTER. You will be asked to repeat the selection again.
- Your keys have now been generated. Notice that this will generate two keys, “id_rsa.pub” and “id_rsa”.
id_rsa.pub is your public key and will be uploaded to your GitHub.
id_rsa is your private key and should not be shared. - Copy your public key to your clipboard with the following command:
pbcopy < ~/.ssh/id_rsa.pub
Be careful to use the filepath that applied to you - Open GitHub, go to Settings, go to SSH & GPG keys, click on New SSH Key, give it whatever name you want and then paste the key.
