Git拒绝访问-权限被拒绝(公钥)

时间:2019-03-25 11:05:34

标签: git macos github openssl macos-sierra

最近,我遇到了一个问题,我无法将提交推送到我一直在处理的github存储库中。错误看起来像这样。 Unable to negotiate with XX.XXX.XX.XX: no matching host key type found. Their offer: ssh-dss

深入研究后,我发现了this stackoverflow answer,但是我调查的所有资料都指向将以下内容添加到~/.ssh/config文件中的相同解决方案。

HostkeyAlgorithms +ssh-dss

这意味着当前我的配置文件大致类似于此(其他内容基于Github的this链接)。

Host *
   AddKeysToAgent yes
   UseKeychain yes
   IdentityFile ~/.ssh/id_rsa
   HostkeyAlgorithms +ssh-dss

但是在添加这一行之后,我遇到了一个新错误。

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

首先,我认为这一定是由于配置文件的更改,所以我从id_rsa删除了id_rsa.pub~/.ssh/,从Github删除了我的公钥,并通过了如here中所述将新的SSH密钥添加到Github中的步骤。那并没有改变任何东西。我也做了几次,以确保我没有错过任何步骤。

我尝试运行ssh -vT git@github.com,结果如下。

OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/USERNAME/.ssh/config
debug1: /Users/USERNAME/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to github.com port 22.
debug1: Connection established.
debug1: identity file /Users/USERNAME/.ssh/id_rsa type 0
debug1: identity file /Users/USERNAME/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version libssh-0.6.5
debug1: no match: libssh-0.6.5
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ssh-dss
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha1 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha1 compression: none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-dss SHA256:yFnU6TvO6zNzGXkSXQFHN1Up7RQnm3qrAVvVdYSpi8A
debug1: Host 'github.com' is known and matches the DSA host key.
debug1: Found key in /Users/USERNAME/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: Will attempt key: /Users/USERNAME/.ssh/id_rsa RSA SHA256:QL+l5m6pNX2a1XqaZ3YYRqJz0An9grTjazb/V4U0j88 explicit agent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/USERNAME/.ssh/id_rsa RSA SHA256:QL+l5m6pNX2a1XqaZ3YYRqJz0An9grTjazb/V4U0j88 explicit agent
debug1: Server accepts key: /Users/USERNAME/.ssh/id_rsa RSA SHA256:QL+l5m6pNX2a1XqaZ3YYRqJz0An9grTjazb/V4U0j88 explicit agent
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).

我在这里看不到有什么对我有帮助的,但是我不是这个问题的专家。

我还运行过ssh-add -l -E md5,结果如下:

4096 MD5:17:05:8f:63:fa:28:0b:ec:1b:39:3d:17:16:61:4d:f1 githubemail@foobar.com (RSA)

与我在Github上看到的用于公开密钥的内容相匹配。

有人知道什么可能是错误的/下一步我应该尝试什么步骤?值得指出的是,我对该存储库具有完全访问权限,并且直到最近我一直在成功地工作了一段时间。

一切顺利 Axel

0 个答案:

没有答案