gpt4 book ai didi

使用 SSH 远程错误 : Load key "/path/to/file_id_rsa": invalid format 的 Git 推送

转载 作者:行者123 更新时间:2023-12-05 02:00:27 25 4
gpt4 key购买 nike

我正在尝试使用 git push 和 SSH 远程从 GitHub CI 操作并收到错误:Load key "/tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa":格式无效

key 在存储库 secret 中。我使用 ssh-keygen -l -v -f key_id_rsa 获取它的信息,它的输出等于我本地机器上的输出。在我的机器上,我可以用这个键推送

GIT_SSH_COMMAND='ssh -v -o StrictHostKeyChecking=accept-new -i /tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa'

我们是 /tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa.pub 文件

git push 输出中的完整ssh -v:

+ git push dest-push-remote gh-pages
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to github.com [140.82.112.4] port 22.
debug1: Connection established.
debug1: SELinux support disabled
debug1: identity file /tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa type 0
debug1: identity file /tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
debug1: Remote protocol version 2.0, remote software version babeld-10d0a39d
debug1: no match: babeld-10d0a39d
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:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /etc/ssh/ssh_known_hosts:1
Warning: Permanently added the RSA host key for IP address '140.82.112.4' to the list of known hosts.
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa RSA SHA256:1xl0uMTaSpIRCnMFIGCf9zC4/CTHXPCroAk1cJIK6qY explicit
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,sk-ssh-ed25519-cert-v01@openssh.com,sk-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,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@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: /tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa RSA SHA256:1xl0uMTaSpIRCnMFIGCf9zC4/CTHXPCroAk1cJIK6qY explicit
debug1: Server accepts key: /tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa RSA SHA256:1xl0uMTaSpIRCnMFIGCf9zC4/CTHXPCroAk1cJIK6qY explicit
Load key "/tmp/341b5794-f0a2-4534-90dd-f791510ec77a_id_rsa": invalid format
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

UPD. 在评论中进行讨论后,我尝试在 Linux 机器上生成新的 key 对并且成功了。在 Linux 机器和 MacOS 机器上生成的不同格式的 key 的问题:

MacOS 生成的 key 以 BEGIN OPENSSH PRIVATE KEY 开头。 Linux 生成的 key 以 BEGIN RSA PRIVATE KEY 开头。我正在调查有什么不同,但如果有任何专家向我建议一些信息,这将很有帮助

最佳答案

如果私钥格式不同,这意味着,如我mentioned here那:

  • 一个平台使用 7.8 之前的 openssh,使用旧的 PEM 每行 64 个字符的格式。
  • 一个使用更新的 OpenSSH 格式,每行 70 个字符。

您可以强制最近的 openSSH 生成旧格式:

ssh-keygen -m PEM -t rsa -P "" -f afile

关于使用 SSH 远程错误 : Load key "/path/to/file_id_rsa": invalid format 的 Git 推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67361592/

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