在本地,我打开了 SSH 代理并添加了我的密钥:
-
$ eval $(ssh-agent) Agent pid 80
-
$ ssh-add Identity added: /c/Users/...../.ssh/id_rsa (.....@........)
在我的~/.ssh/config
,我有这个:
Host example
User root
HostName 123.45.678.912
ForwardAgent yes
一旦我运行ssh example
,我就成功连接了,如果我与 GitHub 建立远程测试连接,我可以看到我已经使用我的转发密钥进行了身份验证:
root@example:~# ssh -vT [email protected]
OpenSSH_8.2p1 Ubuntu-4ubuntu0.5, OpenSSL 1.1.1j 16 Feb 2021
...
debug1: Will attempt key: .....@........ RSA SHA256:abc123/123456abcdefghi/abcdefg12+abcdefghij agent
...
debug1: Offering public key: .....@........ RSA SHA256:abc123/123456abcdefghi/abcdefg12+abcdefghij agent
debug1: Server accepts key: .....@........ RSA SHA256:abc123/123456abcdefghi/abcdefg12+abcdefghij agent
debug1: Authentication succeeded (publickey).
...
Hi ......! You've successfully authenticated, but GitHub does not provide shell access.
有没有办法在没有这样的测试连接的情况下,在远程机器上确定代理转发是否有效?
这个答案建议使用$SSH_AGENT_PID
,但在本地和远程机器上都是空的。