Github & RStudio: how to switch from password to SSH?

Hi folks, this is probably a really simple one but I can't find the answer.

I've been pushing my project to github and having to enter my email & password each time. At points in the past I've been able to have git cache those details but I haven't got that setup currently. I've recently changed to using my personal access token, but that just means I enter a different password.

Having realised (duh) that I could use SSH like I do for Gitlab, I added my SSH key to github. However I don't know how to force rstudio/git to use the SSH rather than the username/password. There doesn't seem to be anything in the Rstudio project options, not the .git config file.

Any tips much appreciated. Using linux. Thanks!

You can set your SSH key on the global options.

Thanks. Interestingly (maybe) I have this setup already looking the same as your screen there, and the public key is the right one that's on my system, which should therefore be the same as on github since I only sent it to github a week or so ago.

So if there's an SSH on the RStudio system then github commit/pish should use that by default? Unless it's wrong somehow maybe?

Key says (on github):
Poseidon-linux-2021 SHA256: [redacted] Added on 11 Feb 2021 Never used — Read/write

Have you configured your project's remote to use ssh instead of https? I think there I s no GUI for doing so after enabling version control in your project but you can do it with git commands from the terminal.

1 Like

That looks like it, thanks.
Per this, in .git/config file, change

url =


url =

Git commit fine, push (in rstudio) hit the problem:

> ssh_askpass: exec(/usr/bin/ssh-askpass):
> No such file or directoryHost key verification failed.
> fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.

In the project folder, opened a terminal, did git push, add RSA fingerprint to known hosts, yes, sorted.

1 Like

This topic was automatically closed after 45 days. 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.