【发布时间】:2021-07-05 09:59:48
【问题描述】:
我创建了一个新的 github 帐户,因此我需要一个新的 ssh 密钥,但是在正确设置 ssh 密钥后,我无法推送我的项目。 创建新的 ssh 密钥后,我在 .ssh 目录中添加了一个配置文件,如下所示:
# one(one@gmail.com)
Host eric
HostName github.com
IdentityFile ~/.ssh/id_rsa
User eric
# two(two@ gmail.com)
Host nuist
HostName github.com
IdentityFile ~/.ssh/github_id
User nuist
然后我运行:ssh -T -v nuist,收到以下指令:
OpenSSH_8.3p1, OpenSSL 1.1.1g 21 Apr 2020
debug1: Reading configuration data /c/Users/Leonard/.ssh/config
debug1: /c/Users/Leonard/.ssh/config line 15: Applying options for nuist
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.255.112] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Leonard/.ssh/github_id type 0
debug1: identity file /c/Users/Leonard/.ssh/github_id-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.3
debug1: Remote protocol version 2.0, remote software version babeld-0913e7e1
debug1: no match: babeld-0913e7e1
debug1: Authenticating to github.com:22 as 'nuist'
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 /c/Users/Leonard/.ssh/known_hosts:1
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: /c/Users/Leonard/.ssh/github_id RSA SHA256:6phvZZlW2357l+xFxmE4xSuMr1EsOFm/owFL2gikjSU explicit agent
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: /c/Users/Leonard/.ssh/github_id RSA SHA256:6phvZZlW2357l+xFxmE4xSuMr1EsOFm/owFL2gikjSU explicit agent
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
nuist@github.com: Permission denied (publickey)
但是,运行我:ssh -T git@github.com 之后,竟然成功了。
我猜测配置文件不起作用,但不能确定。
我看不出问题出在哪里,我也已经在我的 github 帐户中设置了 ssh。
有人可以帮忙吗?我真的很感激。
【问题讨论】: