Skip to content

Instantly share code, notes, and snippets.

@JavaCS3
Last active June 20, 2019 09:39
Show Gist options
  • Save JavaCS3/7219523c686bfb668e09121bbdd811f0 to your computer and use it in GitHub Desktop.
Save JavaCS3/7219523c686bfb668e09121bbdd811f0 to your computer and use it in GitHub Desktop.
How to setup ssh proxy

How to setup ssh proxy

Add the following in your ~/.ssh/config

Host <dest domain/ip>
  ProxyCommand ssh -q -W %h:%p <proxy user>@<proxy domain/ip>

Example

Host 192.168.*
  ProxyCommand ssh -q -W %h:%p proxy@proxy.com

See more in ssh manual man ssh_config

ProxyCommand
             Specifies the command to use to connect to the server.  The command string extends to the end of the line, and is
             executed using the user's shell ‘exec’ directive to avoid a lingering shell process.

             Arguments to ProxyCommand accept the tokens described in the TOKENS section.  The command can be basically anything,
             and should read from its standard input and write to its standard output.  It should eventually connect an sshd(8)
             server running on some machine, or execute sshd -i somewhere.  Host key management will be done using the HostName of
             the host being connected (defaulting to the name typed by the user).  Setting the command to none disables this
             option entirely.  Note that CheckHostIP is not available for connects with a proxy command.

             This directive is useful in conjunction with nc(1) and its proxy support.  For example, the following directive would
             connect via an HTTP proxy at 192.0.2.0:

                ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment