Github ssh-agent 无法推送
Github ssh-agent cannot push
我想通过 SSH 将更改推送到我的 git 存储库。
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.
我已经启动了 ssh-agent 并且 运行。我通过 ssh-add
加载了我的密钥。这是正确的钥匙,我检查了很多次。它也在我的 github 中注册。
当我尝试 git push origin
时,我从上面得到了错误。这是正确的来源。
我也对此进行了很多研究,有人说如果你有多个键指向同一个 git,它会变得混乱或其他什么,但我只加载了一个键。
我也通过 ssh 克隆了 repo。
我该怎么办?我坚持了 4 个多小时,我想不通。
更新
我已经 运行 ssh -v -T git@github.com
并且输出是:
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Connecting to github.com [140.82.121.3] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version babeld-b5f98373
debug1: no match: babeld-b5f98373
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:foobar
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in C:\Users\foobar/.ssh/known_hosts:1
Warning: Permanently added the RSA host key for IP address 'foobar' to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:Ae2CCQzd33Dczv8gPiRiYEWJ7xwBVOU+719JTJ/5fjQ C:\Users\foobar\.ssh\foobar\open_ssh-agent
debug1: Server accepts key: pkalg ssh-rsa blen 279
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
debug1: Authentication succeeded (publickey).
Authenticated to github.com (foobar).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi vivere! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2560, received 2468 bytes, in 0.2 seconds
Bytes per second: sent 10852.5, received 10462.5
debug1: Exit status 1
如果 ssh -Tv git@github.com 确实有效,那么请检查您是否可以通过以下方式联系远程仓库 SSH URL:
git ls-remote git@github.com:<me>/<myRepo>
然后将 URL 与您在本地存储库中注册的那个进行比较 (git remote -v
)
如果相同,请检查 git config -l
的输出:查找其中包含 insteadOf
的任何指令,以防 URL 被其他内容更改。
OP Vivere reports in :
- 必须将密钥命名为
id_rsa
并将其准确保存在 ~/.ssh
中,遵循 this gist;
- 使用错误
ssh-add.exe
(来自 OpenSSH 的那个)
基本上:
- 不要使用 Powershell
- 使用 PATH 未引用的 CMD 会话
C:\Windows\System32\OpenSSH\
我想通过 SSH 将更改推送到我的 git 存储库。
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.
我已经启动了 ssh-agent 并且 运行。我通过 ssh-add
加载了我的密钥。这是正确的钥匙,我检查了很多次。它也在我的 github 中注册。
当我尝试 git push origin
时,我从上面得到了错误。这是正确的来源。
我也对此进行了很多研究,有人说如果你有多个键指向同一个 git,它会变得混乱或其他什么,但我只加载了一个键。
我也通过 ssh 克隆了 repo。
我该怎么办?我坚持了 4 个多小时,我想不通。
更新
我已经 运行 ssh -v -T git@github.com
并且输出是:
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Connecting to github.com [140.82.121.3] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_ed25519-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_xmss type -1
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\s/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version babeld-b5f98373
debug1: no match: babeld-b5f98373
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:foobar
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in C:\Users\foobar/.ssh/known_hosts:1
Warning: Permanently added the RSA host key for IP address 'foobar' to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp521,ecdsa-sha2-nistp384,ecdsa-sha2-nistp256,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:Ae2CCQzd33Dczv8gPiRiYEWJ7xwBVOU+719JTJ/5fjQ C:\Users\foobar\.ssh\foobar\open_ssh-agent
debug1: Server accepts key: pkalg ssh-rsa blen 279
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
debug1: Authentication succeeded (publickey).
Authenticated to github.com (foobar).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi vivere! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2560, received 2468 bytes, in 0.2 seconds
Bytes per second: sent 10852.5, received 10462.5
debug1: Exit status 1
如果 ssh -Tv git@github.com 确实有效,那么请检查您是否可以通过以下方式联系远程仓库 SSH URL:
git ls-remote git@github.com:<me>/<myRepo>
然后将 URL 与您在本地存储库中注册的那个进行比较 (git remote -v
)
如果相同,请检查 git config -l
的输出:查找其中包含 insteadOf
的任何指令,以防 URL 被其他内容更改。
OP Vivere reports in
- 必须将密钥命名为
id_rsa
并将其准确保存在~/.ssh
中,遵循 this gist; - 使用错误
ssh-add.exe
(来自 OpenSSH 的那个)
基本上:
- 不要使用 Powershell
- 使用 PATH 未引用的 CMD 会话
C:\Windows\System32\OpenSSH\