Can't open New Project from Git Repository using SSH

When creating a new RStudio Cloud project from a Git repository, I've always used HTTPS. I recently added SSH keys, and I'm having trouble creating new projects in RStudio using the SSH (rather than HTTPS) Git URL. I am getting a "Cannot access Git repository" error:

This particular repo is public, so repo access is not the problem. Cloning with SSH, rather than HTTPS, is the problem, but I'm not sure how to fix it. I tried setting my RStudio Cloud default Git protocol to SSH using these instructions but it didn't help - I'm still getting the error whenever I try to create a new project using a Git SSH URL.

Update: It looks like my SSH keys (created using credentials::ssh_setup_github()) are stored locally inside the project where they were created, but are not made available to other projects in my RStudio Cloud account.

Is there a way for the SSH keys to be used globally (in each project by default) across my RStudio Cloud account?

1 Like

I'm using personal access tokens, but same issue that PAT seems to be local to a project and doesn't apply across projects within my account.

I haven't tried yet, but I wonder if setting a Base RStudio Project for the workspace will solve this if the issue has been settled in the "base project" you choose?

It looks like it is possible by using the terminal and store the keys in your user directory:

https://bren.zendesk.com/hc/en-us/articles/360015826731-How-to-connect-RStudio-Cloud-with-Github

And for the background information:

1 Like

Thanks, this is a nice suggestion that could work for me, but I would like my students to use this workflow. We are using a "course workspace" in RStudio Cloud, and there is a single base project for the workspace, that I manage. So there would be no way to store each student's credentials in the base project - it's the same base project for everyone in the workspace.

Thanks, I tried this but am still unable to Create a New Project from Git Repository using the SSH URL :frowning: .

Is there a way for the SSH keys to be used globally (in each project by default) across my RStudio Cloud account?

No. SSH keys are stored in the home directory (/home/rstudio-user/) and are not shared across projects. This means that you will need to configure your SSH keys for every project you want to use them with. Obviously, this is not ideal, so it is something we have on our backlog to address. However I do not yet have an ETA for when that might be available.

2 Likes

Yes, I got it to work for one project, but the "home directory" was wiped when I opened another.

@andy_kipp Would we need to add a key to GitHub for every single project in RStudio Cloud then?

Thanks @andy_kipp , this is very helpful. Does personal access token (PAT) access persist across projects in RStudio Cloud? If not, what is the recommended GitHub authentication workflow for RStudio Cloud users? Password authentication is no longer accepted by GitHub.

1 Like

No. Git credentials (including PATs) are NOT persisted across projects. For each project that is created from a GitHub repository, the user will need to supply a username and a PAT to push and pull from that repository. While it is true that password authentication is no longer supported by GitHub, you can use a PAT in place of a password when you push or pull, so the process is nearly the same.

Yes. Or you would need to supply a username + PAT when you push or pull.

Got it, thank you. So, if I understand correctly, RStudio Cloud users cannot use the "New Project from Git Repository" workflow with SSH Git authentication, since the SSH authentication needs to be configured in each new project, before linking with GitHub. Attempts at cloning via SSH into a brand new project will fail due to lack of authentication. Instead, RStudio Cloud users who want to clone a GitHub repo using "New Project from Git Repository" must supply the HTTPS URL from GitHub, then push/pull etc. inside that project using HTTPS authentication, supplying the PAT in place of a password. Is that right?

2 Likes

Yep. That is correct.

1 Like

@andy_kipp I really appreciate your help on this topic. I respectfully ask that this be documented (ideally, prominently) in the RStudio Cloud Guide, RStudio Education materials on teaching with Git + RStudio, etc. It wasn't an issue until recently when GitHub password authentication went away, but the incompatibility of SSH authentication + GitHub cloning in RStudio Cloud doesn't seem to be documented anywhere other than this discussion thread, and many RStudio Cloud users and instructors may have to figure it out the hard way.

2 Likes

Thanks for the suggestion @Debbie_Yuster

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.