Steps to setup GitHub SSH connections
- Create GitHub SSH keys
$ cd ~/.ssh
- Use the ssh-keygen command to create GitHub SSH key pairs:
$ ssh-keygen -o -t rsa -C "[email protected]"
The purpose of the parameters used with the GitHub ssh-keygen command are as follows:
* The -o flag forces the tool to generate SSH keys with the OpenSSH format
* The -t flag specifies they type of SSH keys to create
* The -C flag allows for comments that get added as metadata at the end of the public key
- Open created .pub file
$ ~/.ssh$ cat id_rsa.pub
- GitHub SSH key config
Next, you must configure the GitHub SSH key in the settings of your online account. Log into GitHub, navigate to your account settings, and find the link named “SSH and GPG keys.” Click on this link to create a new GitHub SSH key. Provide a unique name, and paste the value of the private GitHub SSH key you copied earlier.
- Adding your SSH key to the ssh-agent
* Start the ssh-agent in the background.
$ eval "$(ssh-agent -s)"
> Agent pid 59566
* Add your SSH private key to the ssh-agent.
If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
$ ssh-add ~/.ssh/id_ed25519
With the GitHub SSH key setup complete, you can now use the SSH repository GitHub URL to clone from and push to your remote repo.