在 Git Bash 中显示 SSH 密钥文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18845799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Show SSH key file in Git Bash
提问by Kai Schneider
How can I see which SSH key file is used in Git Bash?
如何查看 Git Bash 中使用了哪个 SSH 密钥文件?
I tried "git config --get-all", but I get the error message
我尝试了“git config --get-all”,但收到错误消息
error: wrong number of arguments; usage: git config [options]
错误:参数数量错误;用法:git config [选项]
回答by Jan Krüger
Which SSH key is used isn't determined by Git, but by the SSH client itself. Either the appropriate key is configured in ~/.ssh/config
, or ssh
just tries all keys it can find when connecting to the host. You can see which key ultimately succeeded by connecting to the host with the standard SSH client. For example, when using GitHub:
使用哪个 SSH 密钥不是由 Git 决定的,而是由 SSH 客户端本身决定的。在 中配置了适当的密钥~/.ssh/config
,或者ssh
只是尝试在连接到主机时可以找到的所有密钥。您可以通过使用标准 SSH 客户端连接到主机来查看最终成功的密钥。例如,当使用 GitHub 时:
ssh -v [email protected]
This will give you something a bit like this:
这会给你一些像这样的东西:
[...]
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 ****
[...]
This tells you that the key .../id_rsa2
was the one accepted by the server.
这告诉您密钥.../id_rsa2
是服务器接受的密钥。
回答by MewX
Another solution, in the latest Git Bash, you can type:
另一种解决方案,在最新的 Git Bash 中,您可以键入:
$ git-gui
Then a GUI application is executing, and in the GUI, you can just click Help→ Show SSH Keyto show your SSH key.
然后一个 GUI 应用程序正在执行,在 GUI 中,您只需单击帮助→显示 SSH 密钥即可显示您的 SSH 密钥。
回答by rafi
This command worked for me:
这个命令对我有用:
cat ~/.ssh/id_rsa.pub