Connect with SSH through a proxy

Here’s how to do Richard Christensen’s answer as a one-liner, no file editing required (replace capitalized with your own settings, PROXYPORT is frequently 80):

 ssh USER@FINAL_DEST -o "ProxyCommand=nc -X connect -x PROXYHOST:PROXYPORT %h %p"

You can use the same -o ... option for scp as well, see my superuser answer.


If you get this in OS X:

 nc: invalid option -- X
 Try `nc --help' for more information.

it may be that you’re accidentally using the homebrew version of netcat (you can see by doing a which -a nc command–/usr/bin/nc should be listed first). If there are two then one workaround is to specify the full path to the nc you want, like ProxyCommand=/usr/bin/nc


For CentOS nc has the same problem of invalid option --X. connect-proxy is an alternative, easy to install using yum and works —

ssh -o ProxyCommand="connect-proxy -S PROXYHOST:PROXYPORT %h %p" USER@FINAL_DEST

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)