gpt4 book ai didi

Github ssh-agent 无法推送

转载 作者:行者123 更新时间:2023-12-05 04:52:51 24 4
gpt4 key购买 nike

我想通过 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 加载了我的 key 。这是正确的 key ,我检查了很多次。它也在我的github中注册。

当我尝试 git push origin 时,我从上面得到了错误。这是正确的来源。

我也对此进行了很多研究,有人说如果你有同一个 git 的多个 key ,它会变得困惑或其他什么,但我只加载了一个 key 。

我也通过 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 与您在本地存储库中注册的 URL 进行比较 (git remote -v)
如果相同,请检查 git config -l 的输出:查找其中包含 insteadOf 的任何指令,以防 URL 被其他内容更改。

OP Vivere报告 the comments :

  • 必须将 key 命名为 id_rsa 并将其准确保存在 ~/.ssh 中,遵循 this gist ;
  • 使用错误的 ssh-add.exe(来自 OpenSSH 的)

基本上:

  • 不要使用 Powershell
  • 使用 PATH 未引用 C:\Windows\System32\OpenSSH\
  • 的 CMD session

关于Github ssh-agent 无法推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66373715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com