【发布时间】:2019-08-04 07:45:32
【问题描述】:
如何查看 Git Bash 中使用了哪个 SSH 密钥文件?
我尝试了“git config --get-all”,但收到错误消息
错误:参数数量错误;用法:git config [选项]
【问题讨论】:
标签: git
如何查看 Git Bash 中使用了哪个 SSH 密钥文件?
我尝试了“git config --get-all”,但收到错误消息
错误:参数数量错误;用法:git config [选项]
【问题讨论】:
标签: git
使用哪个 SSH 密钥不是由 Git 决定的,而是由 SSH 客户端本身决定的。在~/.ssh/config 中配置了适当的密钥,或者ssh 只是尝试连接到主机时可以找到的所有密钥。您可以通过使用标准 SSH 客户端连接到主机来查看最终成功的密钥。例如,使用 GitHub 时:
ssh -v git@github.com
这会给你一些类似这样的东西:
[...]
debug1: Offering RSA public key: /home/me/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /home/me/.ssh/id_rsa2
debug1: Server accepts key: pkalg ssh-rsa blen ****
[...]
这告诉您密钥 .../id_rsa2 是服务器接受的密钥。
【讨论】:
另一种解决方案,在最新的 Git Bash 中,你可以输入:
$ git-gui
然后一个 GUI 应用程序正在执行,在 GUI 中,您只需单击 Help → Show SSH Key 即可显示您的 SSH 密钥。
【讨论】:
这个命令对我有用:
cat ~/.ssh/id_rsa.pub
【讨论】: