OS命令行通过GitHub进行身份验证

OS命令行通过GitHub进行身份验证

本文介绍了Mac OS命令行通过GitHub进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试连接到GitHub来验证我的podspec时,我不断遇到以下错误:

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

这似乎是我与GitHub的特定连接,因为从命令行进行克隆会引发相同的错误:

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

通常,我通过Xcode管理VCS,这使我可以输入身份验证凭据,但是我意识到我需要设置ssh密钥.

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.

但是,尝试运行pod spec lintgit clone时,错误仍然存​​在.我重新启动了终端外壳,作为Mac用户(Mojave),我了解到需要在~/.ssh/config上创建一个文件,内容如下:

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

对下一步有任何想法吗?

我在KeyChain Access中看不到密钥.不应该在那里吗?如果是这样,我该如何导入?

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

更新:

尝试使用本文与生成的令牌连接;但仍然会出现相同的错误.还用这些字段更新了我的配置,这些字段可能没有被指向或其他内容.

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

直到尝试使用生成的令牌之前,我都可以成功地使用ssh -T [email protected] ssh进行登录,但是现在出现以下错误:

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

并且还删除了我的〜/.ssh目录,但是没有提示输入密码,仍然超时失败.

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.

有人有反正我可以重设此密码并尝试重新开始吗?还是知道为什么我可以使用ssh -T进行身份验证但无法克隆?

确认我仍然可以通过Xcode访问.下载了Github Desktop并进行了身份验证,因为我读到这会有所帮助.仍然没有提示您输入密码.

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!!!!

推荐答案

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

只要您使用https://...,就可以整天调整SSH配置...它将被忽略.

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

首先尝试使用 SSH URL:git clone [email protected]:myAccount/myRepo.git,然后查看问题是否仍然存在.

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

这篇关于Mac OS命令行通过GitHub进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 21:38