GitHub & SSH (Secure Shell) - bradsorour/notes GitHub Wiki
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_rsausing this command$ vim ~/.ssh/id_rsa.pub
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)
If you don't want to add your passphrase every time, then add the SSH key to the ssh-agent.
- Start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566
- 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/configfile to automatically load keys into the ssh-agent and store passphrases in your keychain.
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
- Add your SSH private key to the ssh-agent and store your passphrase in the keychain.
$ ssh-add -K ~/.ssh/id_rsa