问题原文
原帖链接 · dodov · CC BY-SA 4.0
Locally, I've turned on the SSH agent and I've added my key:
-
$ eval $(ssh-agent) Agent pid 80 -
$ ssh-add Identity added: /c/Users/...../.ssh/id_rsa (.....@........)
In my ~/.ssh/config, I have this:
Host example
User root
HostName 123.45.678.912
ForwardAgent yes
Once I run ssh example, I am successfully connected and if I make a remote test connection to GitHub, I can see that I'm authenticated using my forwarded key:
root@example:~# ssh -vT [email omitted]
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.
Is there a way to determine, on the remote machine, if agent forwarding works, without such a test connection?
This answer suggested using $SSH_AGENT_PID, but it's empty, on both the local and remote machine.
已采纳解答
原帖链接 · asktyagi · CC BY-SA 4.0
If the variable is not set on server, it means that agent forwarding is not working
Forwarding working example.
$ echo "$SSH_AUTH_SOCK"
# Print out the SSH_AUTH_SOCK variable
> /tmp/ssh-6hNGMk10AZC/agent.89543
Not working example
$ echo "$SSH_AUTH_SOCK"
# Print out the SSH_AUTH_SOCK variable
> [No output]
$ ssh -T [email omitted]
# Try to SSH to github
> Permission denied (publickey).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
