Snowball's answer helped a lot. However, I made some modifications to the command and wanted to explain how it works.
Given this situation:
A -------> B -------> C
using A's using B's
ssh key ssh key
~/.ssh/config file and add the host
B through which you want to jump, just how you would normally configure a host:
Then you add the host
C that you want to end up on:
ProxyCommand ssh -T -q -o 'ForwardAgent yes' B 'ssh-add -t 1 && nc %h %p'
ssh -T -q indicates that it should not allocate a pseudo-TTY (
-T) and be quiet (
- once on the jump host
B, we add the key to the SSH keys of
- which only works because we forwarded the SSH agent using
-o 'ForwardAgent yes'.
ssh-add -t 1 indicates that I want the key to be added only for the 1 second needed to authenticate to the final host C;
- and finally,
nc %h %p initiates a
netcat connection to the final host
%h at port
%p (both which will be filled out by SSH based on the information in the
If you need to specify a custom key on
B to use, you can do that by modifying the
ProxyCommand ssh -T -q -o 'ForwardAgent yes' B 'ssh-add -t 1 ~/.ssh/mykey && nc %h %p'