I-DEEL: Inter-Disciplinary Ecology and Evolution Lab
  • Home
  • People
  • Research
  • Publications
  • Open Science
    • Registrations
    • Registered Reports
    • Published Protocols
    • Preprints
    • EDI
    • Other
  • Opportunities
  • Links
  • Blog

Changes to GitHub access for RStudio workflows

22/6/2021

0 Comments

 

by Losia Lagisz and Shinichi Nakagawa

Have you received and email from GitHub titled “[GitHub] Deprecation Notice“? Or you are still creating a new repositories on GitHub using https links to clone repositories into RStudio and your local computer? If so, it is time to change how you access GitHub from RStudio (and from your computer in general).
 
From August 13, 2021, using a password with GitHub will no longer work and token (or SSH key) authentication will be used for GitHub operations (if you are already using two-factor authentication for GotHub, you do not need to change anything). You can read official information about this change here: https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ .

It may seem quite daunting to go through all the details and options. So, below we present two main ways of switching to SSH when using GiTHUB with RStudio. First, setting public SSH key(pair) for your computer. Second, switching remote URLs from HTTPS to SSH for your existing repositories.
​

1. Setting public SSH key for your compute

​Note: This set up needs to be done for each of computers (and accounts) you are using to access GitHub, i.e. each computer (account) should have its own SSH key. More detailed description of SSH and alternative ways of setting up and troubleshooting are available from: https://happygitwithr.com/ssh-keys.html.

1.1. Open RStudio and go to Preferences from the top menu. [for all Windows users, it is Tools -> Global Options (?)]
Picture

1.2. Options box appears. Press on GIV/SVN icon in the left side menu.
Picture
1.3. Press the "Create SSH Key..." button.
Picture
​1.4. Enter Passphrase and Confirm it (optional). Press "Create" button.
Picture
1.5. A a new window with some key info will appear – it confirms that a file with SSH key pair info was created and stored on your computer. Close this window and press "Apply" button at the bottom of the Options window.

1.6. Still in the Options window, press on "View public key" link and copy the content of the new window box to you clipboard.
Picture
1.7. Log into your GitHub account online (via web browser), go to Settings from the top right corner (next to you photo) and select “SSH and CPG keys” from the left-side menu.
Picture
1.8. Press "New SSH Key" green button.
Picture
1.9. In Title box, type e.g. name of your current computer. In Key box, paste your public key copied from RStudio. Press on "Add SSH key" green button below. Confirm access change by entering your GitHub password (if prompted).
Picture
.
1.10. You should get an email from [GitHub] notifying you that a new public key was added to your account
1.11. Restart RStudio.
1.12. From now, when creating a new repository in GitHub use SSH code to create connect your project to your GitHub account (see https://happygitwithr.com/rstudio-git-github.html, just use SSH not https).

2. Switching remote URLs from HTTPS to SSH for your existing repositories

Note: You should have already completed step 1, so that the SSH key is saved in both RStudio and GitHub . Now it is time to point each of your local repositories to its matching SSH link.
2.1. For each repository: open related R project in RStudio. Display current url link used to fetch and push to GotHub for this project by entering in the Terminal pane:
​
git remote -v
You should get output similar to this (with your own USERNAME/REPONAME, where USERNAME is your GitHub username and REPONAME is the name of your GitHub repository):
​
origin https://github.com/USERNAME/REPONAME.git (fetch)
origin https://github.com/USERNAME/REPOSITORY.git (push)


This output shows what sort of url link you are currently using to connect to GitHub.

​2.2. Change your remote's url from https to SSH by typing into the Terminal window (use exactly the same USERNAME/REPONAME as you got in the output of the previous step 2.1.):

git remote set-url origin git@github.com:USERNAME/REPONAME.git

2.3. Verify that the remote URL has changed by repeating the code from step 2.1.:

git remote -v 

The output should look like this:

origin git@github.com:
USERNAME/REPOSITORY.git (fetch)
origin git@github.com:
USERNAME/REPOSITORY
.git (push)

2.4. In RStudio Git pane, try pulling and pushing to GitHub (first time, you will get a message that new key was permanently added).
 
If this approach does not work, the simple way around is to delete a local project folder from your computer and cloning it from GitHub using SSH. If you have any files and sub-folders that are not tracked by git within that folder, remember to store/archive these elsewhere before deleting the folder.
 
You can read more about managing remote repositories using git via Terminal here: 
https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories
0 Comments

    Author

    Posts are written by our group members and guests.

    Archives

    February 2023
    January 2023
    December 2022
    November 2022
    October 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    July 2021
    June 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    August 2020
    July 2020
    June 2020
    April 2020
    December 2019
    November 2019
    October 2019
    September 2019
    June 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    July 2018
    June 2018
    May 2018
    March 2018
    January 2018
    December 2017
    October 2017
    September 2017
    July 2017
    June 2017
    May 2017
    April 2017
    March 2017
    January 2017
    October 2016
    August 2016
    July 2016
    June 2016
    May 2016
    March 2016

    Categories

    All

    RSS Feed

HOME
PEOPLE
RESEARCH
PUBLICATIONS
OPEN SCIENCE
OPPORTUNITIES
LINKS
BLOG

Created by Losia Lagisz, last modified on June 24, 2015