Skip to content

Instantly share code, notes, and snippets.

@kbon
Last active June 26, 2017 09:19
Show Gist options
  • Save kbon/c57eb6b9279779b635b8 to your computer and use it in GitHub Desktop.
Save kbon/c57eb6b9279779b635b8 to your computer and use it in GitHub Desktop.
SSH config partial allowing to hop through an arbitrary host
# Generic throughssh command
Host *.throughssh.*
User root
ProxyCommand ssh -A -q `echo %h | sed -e 's/^[^\.]*\.throughssh\.//'` -W `echo %h | sed -e 's/\.throughssh\.[^\.]*$//'`:%p
GSSAPIAuthentication yes
ForwardX11Trusted yes
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel ERROR
SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
SendEnv XMODIFIERS
# Much easier alternative: some-reachable-host[/inbetween-host]*/final-destination-host
Host */*
User root
ProxyCommand ssh -A -q $(echo %h | sed -e 's/^\([^\/]*\)\/.*$/\1/') -W $(echo %h | sed -e 's/^[^\/]*\///'):%p
GSSAPIAuthentication yes
ForwardX11Trusted yes
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel ERROR
SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
SendEnv XMODIFIERS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment