繁体   English   中英

Mac OS 命令行使用 GitHub 进行身份验证

[英]Mac OS command line authenticating with GitHub

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

致命:无法访问“ https://github.com/myAccount/myRepo.git/ ”:无法连接到 159.82.13.140 端口 80:操作超时

这似乎是我与 GitHub 的具体联系,因为从命令行克隆会引发相同的错误:

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 密钥。

设置后,它看起来应该可以工作:

ssh -T git@github.com
Hi myAccount! You've successfully authenticated, but GitHub does not provide shell access.

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

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

对下一步有什么想法吗?

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

更新:

尝试使用本文连接生成的令牌; 但仍然得到同样的错误。 还用这些字段更新了我的配置,这些字段可能没有被指向或其他东西......

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 git@github.com成功进行 ssh 登录,但现在出现以下错误:

ssh_exchange_identification: Connection closed by remote host 

不知怎的,我让它变得更糟了? 尝试使用以下命令重置:

git config --global credential.helper osxkeychain

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

虽然我可以再次通过直接连接成功:

ssh -T git@github.com
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 并进行身份验证,因为我读到这会有所帮助。 仍然没有提示输入密码。

brew install hub

这提示我输入密码,但仍然超时!!!!

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

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

首先尝试使用SSH URL: git clone git@github.com:myAccount/myRepo.git ,看看问题是否仍然存在。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM