GitHub & SSH (Secure Shell) - bradsorour/notes GitHub Wiki

Create a new SSH Key for your GitHub profile

This is required in order to push changes to the remote repositories.

  • Login to GitHub and go to Profile → Settings → SSH and GPG keys
  • Create a new SSH Key
  • Copy this key to here: /Users/<user>/.ssh/id_rsa using this command $ vim ~/.ssh/id_rsa.pub

Update the link to your remote repositories

Within GitHub, copy the link of the remote repo (using the 'clone or download' link, ensuring Use SSH option is selected).

Update your local repositories using the following command:

$ git remote set-url origin <copied repo url from github>

Check that the remote repository url is now correct with the following command:

$ git remote -v

The remote repository should have the following format:

origin [email protected]:hmcts/ia-ccd-e2e-tests.git (fetch)
origin [email protected]:hmcts/ia-ccd-e2e-tests.git (push)

Adding your SSH key to the ssh-agent

If you don't want to add your passphrase every time, then add the SSH key to the ssh-agent.

  1. Start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566
  1. If you're using macOS Sierra 10.12.2 or later (currently on macOS Mojave 10.14.5), you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.
Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa
  1. Add your SSH private key to the ssh-agent and store your passphrase in the keychain.
$ ssh-add -K ~/.ssh/id_rsa
⚠️ **GitHub.com Fallback** ⚠️