如何验证git使用特定的公钥文件?

rip*_*234 5 git ssh

我向第三方发送了我的公共SSH密钥,他们用它来为我添加访问特定存储库的权限.但是,当我尝试git clone时,我收到错误(事实上,我被要求输入密码).

我以前遇到的问题是我认为是我的公钥,实际上并不是我的git客户端使用的公钥.我的问题:

如何验证git客户端使用哪个SSH密钥?

>ssh git@git.wpengine.com info
git@git.wpengine.com's password:     <--- this shouldn't happen
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 8

您可以使用~/.ssh/config文件来指定要使用的确切主机名,用户私钥:

Host wpengine 
user git
hostname git.wpengine.com
IdentityFile ~/.ssh/myPrivateKey
Run Code Online (Sandbox Code Playgroud)

这样,关于使用哪个密钥没有歧义.

ssh -vvvT wpengine
Run Code Online (Sandbox Code Playgroud)

该命令将告诉您发生了什么.
通常,公钥会错误地添加到~/.ssh/authorized_keys服务器端.