Mercutio
Mercutio

Reputation: 1296

Mac OS command line authenticating with GitHub

While trying to connect to GitHub to validate my podspec, I keep getting the following error:

fatal: unable to access 'https://github.com/myAccount/myRepo.git/': Failed to connect to 159.82.13.140 port 80: Operation timed out

It seems to be my connection to GitHub specifically, because cloning from the command line throws the same error:

git clone https://github.com/myAccount/myRepo.git ~/Desktop/testClone
Cloning into '/Users/myAccount/Desktop/project'...
fatal: unable to access 'https://github.com/myAccount/myRepo.git/': Failed to connect to 159.82.13.140 port 80: Operation timed out

Normally I manage VCS through Xcode, which lets me input my auth credentials, but I realized I need to setup ssh keys.

After setting that up, it looks like it should work:

ssh -T [email protected]
Hi myAccount! You've successfully authenticated, but GitHub does not provide shell access.

However the error persists both when trying to run pod spec lint and git clone. I've restarted my terminal shells, and as a Mac user (Mojave) I learned that I need to create a file at ~/.ssh/config with the below text:

Host github.com
   AddKeysToAgent yes
   UseKeychain yes
   IdentityFile ~/.ssh/id_rsa

Any idea on next steps?

I'm not seeing the key in my KeyChain Access. Shouldn't it be there? If so, how do I import it?

UPDATE:

Tried using this article to connect with a generated token; but still get the same error. Also updated my config with these fields, which may not be getting pointed to or something...

Host github.com   
User git
Hostname github.com
PreferredAuthentications ~/.ssh/id_rsa.pub
Port 80
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa

Up until I attempted to use the generated token, I was able to successfully ssh in with ssh -T [email protected] but now I get the following error:

ssh_exchange_identification: Connection closed by remote host 

Somehow I made it worse? Tried reseting with the following command:

git config --global credential.helper osxkeychain

And also removed my ~/.ssh directory, but not getting prompted for a password and still getting the timeout failure.

Although I can succeed with a direct connection again:

ssh -T [email protected]
The authenticity of host 'github.com (192.30.255.112)' can't be established.
RSA key fingerprint is SHA256.*******
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.255.112' (RSA) to the list of known hosts.
Hi ******! You've successfully authenticated, but GitHub does not provide shell access.

Anyone have anyway I can reset this and try to start over? Or any idea why I can authenticate with ssh -T but can't clone?

Confirmed I can still access through Xcode. Downloaded Github Desktop and authenticated because I read that would help. Still not getting prompted for a password.

brew install hub

This prompted me for a password, but still timed out!!!!

Upvotes: 3

Views: 6242

Answers (1)

VonC
VonC

Reputation: 1323803

git clone https://github.com/myAccount/myRepo.git ~/Desktop/testClone

As long as you are using https://..., you can tweak your SSH configuration all day long... it will be ignored.

Try using first an SSH URL: git clone [email protected]:myAccount/myRepo.git, and see if the issue persists.

Upvotes: 3

Related Questions