SSH 和 GIT 身份验证突然停止工作

SSH 和 GIT 身份验证突然停止工作

几个月来我一直很高兴地从我的存储库中提取数据,直到现在......:'(

这是 git 第一次要求我将 github.com 添加到 known_hosts 文件中。它以前从来没有这样做过,直到我对下面的问题回答“是”后,我才有了 .ssh 目录。

# git pull

Host 'github.com' is not in the trusted hosts file.
(ssh-rsa fingerprint md5 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48)
Do you want to continue connecting? (y/n) y

/usr/bin/ssh: Connection to [email protected]:22 exited: No auth methods could be used.
fatal: Could not read from remote repository.

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

我不知道到底发生了什么变化......做了git status一些工作,但我什么也做不了。

我无法执行此操作ssh -vvv,因为这是在一个小型嵌入式 Linux 系统上,而且显然 ssh 没有使用详细选项进行编译,所以我真的不知道发生了什么。

我是否应该能够在不添加 github ssh 密钥的情况下从 repo 中提取?这一切都发生在一个小型嵌入式系统上,我将其部署在各个地方,所以我不想添加任何帐户详细信息,我只希望它从 github 中提取最新版本。

我的 git 配置:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = [email protected]:MyUser/MyRepo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

我尝试将 git 更改为 https,但却出现证书错误。(我删除了用户和 repo 名称)

答案1

正如您所说,这是在嵌入式系统上,请确保日期和时间正确。我遇到了一些 HTTPS 问题,系统基本上会认为它是在 1970 年并拒绝 Github 证书。

您还可以在这里找到预期的 SSH 主机密钥:https://help.github.com/articles/github-s-ssh-key-fingerprints/。当一些以前正常工作的东西现在出现异常时,最好检查一下它们,这可能是中间人所为。

答案2

我没有找到根本原因,但找到了解决方案。

Github 指出建议使用 HTTPS,因为与 SSH 相比,它更容易穿过防火墙和代理: https://help.github.com/articles/which-remote-url-should-i-use/

解决方案:将 URL 更改为 https。并配置 git: git config --global http.sslVerify false如下所述: https://confluence.atlassian.com/fishkb/unable-to-clone-git-repository-due-to-self-signed-certificate-376838977.html

我会将此解决方案的质量评定为:解决方法。如果有人有更好的方法,我很乐意听听 ;-)

相关内容