在git bash中显示ssh密钥文件

Kai*_*der 53 git

如何查看git bash中使用的ssh密钥文件.我试过"git config --get-all",但是我收到错误消息"错误:参数数量错误;用法:git config [options]"

Jan*_*ger 77

使用哪个SSH密钥不是由git决定的,而是由SSH客户端本身决定的.可以配置相应的密钥~/.ssh/config,也ssh可以尝试连接到主机时可以找到的所有密钥.您可以通过使用标准SSH客户端连接到主机来查看最终成功的密钥.例如,使用Github时:

ssh -v git@github.com
Run Code Online (Sandbox Code Playgroud)

这会给你一些像这样的东西:

[...]
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 ****
[...]
Run Code Online (Sandbox Code Playgroud)

这告诉您密钥.../id_rsa2是服务器接受的密钥.

  • 这在没有默认命令行 ssh 客户端运行的 Windows 上如何工作? (2认同)
  • 只需使用git-bash,它就有命令行ssh. (2认同)
  • Windows 版 Git 通常包含自己的 SSH 客户端,可以从 Git Bash 获取该客户端。 (2认同)

Mew*_*ewX 38

另一个解决方案,在最新的git bash中,你可以输入:

$ git-gui
Run Code Online (Sandbox Code Playgroud)

然后执行GUI应用程序,在GUI中,您只需单击__CODE__以显示SSH密钥.


小智 9

这个命令对我有用:

cat ~/.ssh/id_rsa.pub
Run Code Online (Sandbox Code Playgroud)

  • 仅当您在默认位置使用默认 RSA 密钥时,此操作才有效。如果您的密钥有其他名称或您使用其他类型(如 ED25519),则此方法不起作用。 (2认同)