GitHub 提交工作正常但突然:权限被拒绝(公钥)
GitHub commits were working OK but suddenly: Permission denied (publickey)
几天前,我工作正常,并且毫无问题地向 GitHub 提交内容。
昨天我开始在 "git push" 收到这个:
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the
list of known hosts. Permission denied (publickey). fatal: Could not
read from remote repository.
Please make sure you have the correct access rights and the repository
exists.
1) 我有 ssh 密钥并检查了我的 GitHub 帐户,指纹匹配 (ssh-keygen -lf github_rsa.pub).
2) 尝试生成一个新密钥,以防万一,它是 "github2_rsa",从网络上将 public 密钥添加到 GitHub,并更改了我的 ssh 配置。将 IdentityFile 更改为使用 github2_rsa 而不是 github_rsa,并添加了 User=git(建议添加它的解决方案)
Host github.com
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
User=git
IdentityFile=~/.ssh/github2_rsa
3) 再次尝试推送,出现同样的错误。
4) ssh -vT git@github.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Applying options for github.com
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Connection established.
debug1: identity file /.ssh/github2_rsa type -1
debug1: Remote protocol version 2.0, remote software version libssh_0.7.0
debug1: no match: libssh_0.7.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-sha1 none
debug1: kex: client->server aes128-cbc hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/github2_rsa
debug1: No more authentication methods to try.
Permission denied (publickey).
我的环境是一台装有 WinXP 的旧虚拟机(是的,我知道,是针对项目需要的特定环境),并且使用 SmartGit 提交,然后当它开始失败时我从命令行尝试,但遇到了同样的问题。
已经在 Whosebug 上尝试了很多解决方案,但都没有用。
例如:
一些解决方案说 "ssh-add xxx" 运行 ssh-add 我得到:
Could not open a connection to your authentication agent.
其他人说使用:eval "$(ssh-agent -s)" 但在windows eval 不被识别为命令。
昨天我发生了类似的事情,无论我用 SSH 做什么,它都不让我推送。
我的解决方案非常愚蠢。我只需要重新启动 iterm (iterm2)。我不知道你有没有尝试过,但希望如果你重新启动整个过程它会起作用。
我今天 运行 在 Big Sur 上讨论了这个问题,我在推送到 GitHub 时突然得到 git@github.com: Permission denied (publickey)
。重启没有帮助。 运行 进入这个为我修复它的答案:https://apple.stackexchange.com/questions/254468/macos-sierra-doesn-t-seem-to-remember-ssh-keys-between-reboots.
简而言之,问题是 ssh 代理丢失了我的 ssh 密钥。 运行 ssh-add -A
有效(直到下次重启?)但更好的解决方案是将以下内容添加到我的 ~/.ssh/config
:
Host *
AddKeysToAgent yes
UseKeychain yes
几天前,我工作正常,并且毫无问题地向 GitHub 提交内容。
昨天我开始在 "git push" 收到这个:
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts. Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
1) 我有 ssh 密钥并检查了我的 GitHub 帐户,指纹匹配 (ssh-keygen -lf github_rsa.pub).
2) 尝试生成一个新密钥,以防万一,它是 "github2_rsa",从网络上将 public 密钥添加到 GitHub,并更改了我的 ssh 配置。将 IdentityFile 更改为使用 github2_rsa 而不是 github_rsa,并添加了 User=git(建议添加它的解决方案)
Host github.com
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
User=git
IdentityFile=~/.ssh/github2_rsa
3) 再次尝试推送,出现同样的错误。
4) ssh -vT git@github.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Applying options for github.com
debug1: Connecting to github.com [192.30.253.113] port 22.
debug1: Connection established.
debug1: identity file /.ssh/github2_rsa type -1
debug1: Remote protocol version 2.0, remote software version libssh_0.7.0
debug1: no match: libssh_0.7.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-sha1 none
debug1: kex: client->server aes128-cbc hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/github2_rsa
debug1: No more authentication methods to try.
Permission denied (publickey).
我的环境是一台装有 WinXP 的旧虚拟机(是的,我知道,是针对项目需要的特定环境),并且使用 SmartGit 提交,然后当它开始失败时我从命令行尝试,但遇到了同样的问题。
已经在 Whosebug 上尝试了很多解决方案,但都没有用。
例如:
一些解决方案说 "ssh-add xxx" 运行 ssh-add 我得到:
Could not open a connection to your authentication agent.
其他人说使用:eval "$(ssh-agent -s)" 但在windows eval 不被识别为命令。
昨天我发生了类似的事情,无论我用 SSH 做什么,它都不让我推送。
我的解决方案非常愚蠢。我只需要重新启动 iterm (iterm2)。我不知道你有没有尝试过,但希望如果你重新启动整个过程它会起作用。
我今天 运行 在 Big Sur 上讨论了这个问题,我在推送到 GitHub 时突然得到 git@github.com: Permission denied (publickey)
。重启没有帮助。 运行 进入这个为我修复它的答案:https://apple.stackexchange.com/questions/254468/macos-sierra-doesn-t-seem-to-remember-ssh-keys-between-reboots.
简而言之,问题是 ssh 代理丢失了我的 ssh 密钥。 运行 ssh-add -A
有效(直到下次重启?)但更好的解决方案是将以下内容添加到我的 ~/.ssh/config
:
Host *
AddKeysToAgent yes
UseKeychain yes