Git SSH 公钥指纹与本地机器上的不匹配

Git SSH 公钥指纹与本地机器上的不匹配

我正在尝试通过 SSH 进入我的 github 帐户。我将我的公钥添加到我的 github 帐户,它显示的指纹如下

SHA256:aYqWu+zL3hIOWTEGvneI90fehVQt9kuGVN7ov8WlTk8

当我通过 SSH 连接到 git 时,它拒绝了我

permission denied(publickey)

然后我运行 SSH -v 并看到我的客户端提供的公钥为

RSA SHA256:aYqWu+zL3hIOWTEGvneI90fehVQt9kuGVN7ov8WlTk8 [email protected]

我的有额外的用户名@主机。

有人能帮我摆脱这个问题吗?提前谢谢了!

** 编辑 **

我的输出ssh -v [email protected]

OpenSSH_7.8p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/macbookpro/.ssh/config
debug1: /Users/macbookpro/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to github.com port 22.
debug1: Connection established.
debug1: identity file /Users/macbookpro/.ssh/id_rsa type 0
debug1: identity file /Users/macbookpro/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.8
debug1: Remote protocol version 2.0, remote software version babeld-0913e7e1
debug1: no match: babeld-0913e7e1
debug1: Authenticating to github.com:22 as 'dungtinhhd123'
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: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] 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 /Users/macbookpro/.ssh/known_hosts:17
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=<[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],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:aYqWu+zL3hIOWTEGvneI90fehVQt9kuGVN7ov8WlTk8 /Users/macbookpro/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

答案1

这是我的错误。我应该ssh -T [email protected]ssh -T [email protected]

答案2

RSA SHA256:aYqWu...8WlTk8[电子邮件保护]

这 ”[电子邮件保护]“公钥的”部分只是注释,无所谓,一般会填写创建该密钥的账户,以帮助识别密钥。

如果要删除注释,包含公钥的文件是一个文本文件。您可以使用文本编辑器编辑该文件并删除注释部分。

答案3

密钥是否已加载到 ssh-agent 中?

你跑步的时候看到它了吗ssh-add -l

您可以在 macOS 上添加它,ssh-aadd -K这会将条目放入您的钥匙串中。

相关内容