I always forget how to use SSH agent key forwarding when using Mosh over to a server.
I mosh to a server and can’t SSH to places:
$ mosh sonar.local
roadmr@sonar:~$ ssh bazaar.launchpad.net
roadmr@bazaar.launchpad.net: Permission denied (publickey).
Run the SSH agent, then export the variables it spits out:
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-tW6qDmkDeLn2/agent.1744897; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1744898; export SSH_AGENT_PID;
echo Agent pid 1744898;
$ SSH_AUTH_SOCK=/tmp/ssh-tW6qDmkDeLn2/agent.1744897; export SSH_AUTH_SOCK;
$ SSH_AGENT_PID=1744898; export SSH_AGENT_PID;
One can also just source that:
$ eval $(ssh-agent -s)
Agent pid 1234141
Next, add your keys:
$ ssh-add ~/.ssh/id_rsa.something
Identity added: /home/roadmr/.ssh/id_rsa.something (/home/roadmr/.ssh/id_rsa.something)
And now SSH should work using key authentication.
$ ssh bazaar.launchpad.net
X11 forwarding request failed on channel 0
No shells on this server.
Connection to bazaar.launchpad.net closed.
# The above is successful, the server did accept the connection \o/
I don’t even know/understand how this works :)