Set up git authentication

Git does not allow password authentication for pushing/pulling your repositories. Instead, we will use an ssh public key to authenticate your identity.

In this method of authentication you generate a public key and a private key. The private key stays on your computer (in this case your Jetstream instance) and the public key is given to 3rd parties who will want to verify your identity (in this case GitHub).

When you attempt to login to GitHub a program called SSH tests to see if your computer has the matching private key.

Create a GitHub Account

If you do not have a GitHub account, please go to github.com and create an account.

Generate a ssh key pair

You can either generate a ssh key pair at the command line or in Rstudio. For this class, we will use Rstudio.

  1. Open Rstudio on your Jetstream instance.
  2. Choose Tools > Global options from the pull-down menu.
  3. From the options box, click on Git/Svn on the left hand tab side
  4. Click Create RSA Key...
  5. I usually don’t create a passphrase. If you do it makes things a bit more complicated to set up, see below.
  6. Click Create
  7. Click Close
  8. Click View public key
  9. Press ctrl+c to copy the key to your clipboard.

ONLY DO THIS if you created a passphrase in step 5:

If you created a passphrase for your ssh key in step 6 above, you need to add it to the system.

In a Linux shell/terminal, make sure ssh-agent is running:

$ eval "$(ssh-agent -s)"
# you should get Agent pid 59566, but with a different number

Then add your key.

ssh-add ~/.ssh/id_ed25519

For more info, or instructions on how to do this on Mac or Linux, see section 11.4.3 at Happy Git with R

Add your public key to github

Go to github.com and login to your account

Click on the your profile icon near the upper right hand side and then select settings.

Click on SSH and GPG keys on the left hand side

Click on New SSH Key, upper right hand side

Enter a name for your key, paste in your public key, then press add SSH key

Test the connection

Open a linux terminal (not R) and type:

ssh -T git@github.com

You may get a warning. Go ahead and type yes. You should then get a message that you have successfully authenticated.

Clone repositories using ssh

In order to use the public key / private key authentication you must clone your repositories using ssh instead of https.

For example (no action required now)

Click on “use ssh” as shown below BEFORE cloning any future repositories.

If you are successful, you should now see “Clone with SSH”

You can now copy the URL for cloning.

Now you should be all set!

Use the SSH URL method for cloning future repositories