Skip to content

Instantly share code, notes, and snippets.

@lorenzosaino
Last active June 22, 2018 20:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzosaino/d046d2733f27a2f9f303 to your computer and use it in GitHub Desktop.
Save lorenzosaino/d046d2733f27a2f9f303 to your computer and use it in GitHub Desktop.
SSH config to connect to an SSH server through an SSH proxy without netcat
# These are SSH configuration examples to connect to an SSH server via
# an SSH proxy. These solutions, differently from other solutions found
# on the Web, do not require netcat.
#
# CLIENT -------- PROXY_HOST ------- TARGET_HOST
#
# This config entry allows you to connect to a specific machine behind an
# SSH proxy
Host <TARGET_HOST>
HostName <TARGET_IP_ADDRESS_OR_HOSTNAME>
User <USERNAME_ON_TARGET>
ProxyCommand ssh -q -A -x <PROXY_HOST> -W %h:22
# This config entry allows you to connect to any machine behind an SSH
# proxy just specifying a suffix that indicates to SSH to connect through
# the proxy
Host *.<SUFFIX>
User <USERNAME_ON_TARGET>
ProxyCommand ssh -q -A -x <PROXY_HOST> -W `basename %h .<SUFFIX>`:22
@HarrisonMc555
Copy link

HarrisonMc555 commented Jun 22, 2018

I tried several different ~/.ssh/config file strategies that didn't work because I don't have access to netcat on the proxy host. This finally did the trick, thanks for sharing!

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