Sunday, May 2, 2021

How to use Github repository in SSH mode?

It is preferred that you use SSH to check in code. You will need an SSH key associated with your GitHub account to do this. You can follow the guide created by GitHub, or the steps below.

The following steps are for MacOS. Follow the guide linked above for other operating systems.
  1. Generate an SSH private-public key pair. Open a terminal on your machine and enter
    • ssh-keygen -t rsa
  2. You will be asked where to save the key. The default (~/.ssh/id_rsa) will suffice.
  3. You will be asked for a secure passphrase. If you enter one, you will be asked for this phrase every time you commit changes. Be sure to remember it.
  4. Add the newly generated private key to your SSH agent. Use the following command.
    • ssh-add -K ~/.ssh/id_rsa
  5. Add the newly generated public key (~/.ssh/ to GitHub. Go to your account settings and select "SSH and GPG keys". Press "New SSH key".
  6. Give your key a meaningful title (i.e. your computer's name or "Work Laptop")
  7. Copy the public key. The easiest way to do this is with the following command. Alternatively you may open ~/.ssh/ with your favourite text editor and copy it.
    • pbcopy < ~/.ssh/
  8. Paste the key into the "Key" box. Press "Add SSH key".

No comments:

Post a Comment