Russ Lenth
Russ Lenth

Reputation: 6780

Switching RStudio project to SSH authentication

OK, I am stumped. For the past couple of months, I have been getting stern messages occasionally from GitHub warning me that I committed my R package using password authentication, and that will be going away. Fine. So I'd love to switch; but...

I looked at various help files. I have gotten R to generate an RSA key. I have copied that key to my GitHub account. I have run ssh-add. After all this, I push an update and find that my SSH key info on GitHub still says it has never been used.

I seemed to find something helpful here. I in fact verified that my remote origin comes out as https://github.com/rvlenth.git which indicates that it's still set up for password authentication. So I did what was suggested there to remove that origin. It suggests looking for something (shown in a little picture) that would give me the new link, but I can't find it on my repository. It looks like it should be [email protected]:rvlenth/emmeans, so, like a fool, I ran git remote add origin [email protected]:rvlenth/emmeans.

It seemed to accept that, but now the pull and push buttons in my RStudio interface are grayed out. I tried to revert back to the https setup, and am still grayed-out.

What do I do to get this to work? I'm feeling under duress because GitHub's going to shut me down if I can't figure out how to do this.

Update

OK, I found the green button and copied the URL it gives for SSH authentication. I also created a new key, typing-in my GitHub password in the process, and copied the public key to GitHub. I have an email from GitHub confirming that. It still fails. In fact, I tried just creating a new project and it wouldn't even work for that:

>>> C:/Program Files/Git/bin/git.exe clone --progress [email protected]:rvlenth/emmeans.git emmeans
Cloning into 'emmeans'...
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Update 2

This is what I get after following up on @torek's suggestion

$ ssh -Tvvv [email protected]
OpenSSH_8.4p1, OpenSSL 1.1.1i  8 Dec 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/c/Users/rlenth/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/c/Users/rlenth/.ssh/known_hosts2'
debug2: resolving "github.com" port 22
debug2: ssh_connect_direct
debug1: Connecting to github.com [140.82.112.4] port 22.
debug1: connect to address 140.82.112.4 port 22: Connection timed out
ssh: connect to host github.com port 22: Connection timed out

So it looks like I have a pretty new version of ssh (apparently from having reinstalled the latest version of git)

Earlier, I had done:

$ ls -l ~/.ssh
total 5
-rw-r--r-- 1 rlenth 197121 1766 Mar  3 16:05 id_rsa
-rw-r--r-- 1 rlenth 197121  400 Mar  3 16:05 id_rsa.pub

$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /c/Users/rlenth/.ssh/id_rsa:
Identity added: /c/Users/rlenth/.ssh/id_rsa (/c/Users/rlenth/.ssh/id_rsa)

... and I entered the passphrase for my GitHib account. It looks like my home directory is being resolved correctly. Do I need to create a known_hosts file or something?

Update 3

Since update 2, I have done:

With all these changes, I still get a timeout when I do ssh -Tvvv [email protected]. So I also tried (with no luck testing any of these)

Is there anybody out there who has successfully set up SSH authentication with Windows? I really need your help!

Update 4

I gave up on getting SSH to work. Instead, I followed GitHub's instructions for creating a personal access token. That seems to work, so far. Either that, or it's still using my password and I'll get another blaming e-mail about it. Time will tell -- but I am at least back up and running.

Update n

After changing a firewall setting in my router (allow peer-to-peer apps), I am now able to authenticate via SSH. Finally. For those who may be interested, the router in question is the one provided by Mediacom: Technicolor TC8305C.

Upvotes: 2

Views: 1232

Answers (1)

VonC
VonC

Reputation: 1324977

ssh: connect to host github.com port 22: Connection timed out

As long as you see this error, no amount of private key/passphrase will help. SSH does not even get to the authentication phase.

I also created a new key, typing-in my GitHub password in the process

When you create a new key, you don't have to enter a passphrase (I would not, at first, for testing SSH).
And if you do enter a passphrase (which will protect your private key by encrypting it), it does not have to be your GitHub password (actually, it should not, as a best practice: don't reuse passwords)

The OP Russ Lenth confirms in the comments a firewall issue:

I logged-on to my router and changed a firewall setting to not block peer-to-peer applications.
Now I can connect via SSH.

Upvotes: 1

Related Questions