且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在git bash中显示ssh密钥文件

更新时间:2023-02-07 12:26:54

使用的SSH密钥不是由git决定的,而是由SSH客户端自己决定的。可以在〜/ .ssh / config ssh 中配置适当的密钥,只需尝试所有可以找到的密钥连接到主机。通过使用标准SSH客户端连接到主机,您可以看到最终成功的密钥。例如,在使用Github时:

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 -v git@github.com

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

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 ****
[...]

这告诉你关键的 ... / id_rsa2 是服务器接受的关键字。

This tells you that the key .../id_rsa2 was the one accepted by the server.