Skip to content

Instantly share code, notes, and snippets.

@ebirn
Last active July 25, 2018 10:42
Show Gist options
  • Save ebirn/5604a1995d8813f04a6ce0f43ddfabbd to your computer and use it in GitHub Desktop.
Save ebirn/5604a1995d8813f04a6ce0f43ddfabbd to your computer and use it in GitHub Desktop.
ssh jump host forwarding config
#
# see also:
# https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing
# http://blog.scottlowe.org/2015/12/11/using-ssh-multiplexing/
#
# you may want to use connection multiplexing on the jumphost
Host jump-host
Hostname jump-host.example.com
ForwardAgent yes
ControlPath ~/.ssh/cm-%r@%h:%p
ControlMaster auto
ControlPersist 10m
# this can also be chained, i.e. local->target_host->target_host2->...
Host target-host
ProxyCommand ssh -W %h:%p jump-host
# one-liner:
# ssh -o ProxyCommand="ssh -W %h:%p proxy_host" target_host
@ebirn
Copy link
Author

ebirn commented Nov 20, 2016

use this in your client ssh config in ~/.ssh/config

the multiplexing will set up one persistent connection to the jump host (that will remain for up to 10 min when unused)

multiple hosts with ProxyCommand statement can be chained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment