无法通过ssh连接到github

时间:2015-09-03 23:31:04

标签: git github ssh

我试图从我新安装的linux机器上运行带有fluxbox的manjaro,在github上克隆我的一个存储库。我设置了user.name和user.email并上传了正确的ssh密钥。但我总是得到

The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? 
Host key verification failed.
fatal: Could not read from remote repository.

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

我用谷歌搜索它,发现我应该{i}删除我的known_hosts文件中的github但是known_hosts文件还没有存在,因为我刚刚完成了一个新的linux安装。< / p>

所以我尝试ssh-keygen -R github.com给了我

ssh -vT git@github

这是我的头脑。谁能告诉我出了什么问题,也许可以解决这个问题?

5 个答案:

答案 0 :(得分:47)

您是否尝试将github添加为已知主机?

如果您有一个现有的known_hosts文件并且不想覆盖(如评论中建议的@Puce),请使用此文件。

ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts

这会将rsa密钥添加到known_hosts的末尾。

如果您不知道known_hosts是什么/意味着什么,或者您从未参与其中,那么您可以简单地写一个新的,但请注意,如果您有任何内容,则会删除现有的。< / p>

ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts

答案 1 :(得分:1)

第1步:生成密钥

- cd   ~/.ssh

- ssh-keygen -t rsa -b 4096 -C "email@email.com"

注意- 密钥仅对您可读:

chmod 400 ~/.ssh/id_rsa

如果您需要密钥可读写:

chmod 600 ~/.ssh/id_rsa

第2步:检查内容并复制

cat ~/.ssh/nameOfFile.pub | pbcopy

第3步:将SSH密钥配置到Bitbucket中(类似于Github)

GOTO设置=> SSHKEY

- Add what you copied in Step 2 and give it a name

第4步:使用SSH协议克隆您的存储库

git clone git@bitbucket.org:{username}/repo.git

git clone git@github.com:{username}/repo.git

这应该可以工作

如果仍然出现此错误

[
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
]

请按照以下步骤操作。

i. ssh -T hg@bitbucket.org OR ssh -T hg@github.com depending on which you are using { This will attempt to create a connection to Bitbucket OR Github Cloud ).

ii. If you do not see a message similar  to (logged in as username.). Go to the next step

iii. ssh-add ~/.ssh/identity (identity is whatever name you saved the file when generating a key)

iv. You will get this message (Identity added: /path to ssh file/.ssh/mywork (youremail@email.com)
v. You can now clone your repository.

答案 2 :(得分:0)

如果您只想克隆存储库,但也使用bitbucket或任何其他git工具,请尝试使用https而不是ssh

答案 3 :(得分:0)

由于重新安装了Windows,因此在使用新生成的ssh密钥设置原点时,也会发生此问题。

当我更新ssh密钥路径(新生成)时,它使用以下代码解决了我的问题

 eval $(ssh-agent -s)
 ssh-add /d/key    **(path of new key d:/key)**

答案 4 :(得分:-4)

我没有关于git的专家,但看着这似乎是服务器和你的PC之间的连接出了问题。 它说:

$this

当您收到数据时,听起来像是出了问题。您是否多次尝试过并得到相同的响应?

尝试检查您的互联网连接,或者github是否暂时脱机。

相关问题