SSH Gateway in ~/.ssh/config

gatewayssh

What is the difference between the following?

Host foo
    ProxyCommand ssh example.com -- /usr/bin/nc %h %p 2> /dev/null

and

Host foo
    ProxyCommand ssh -W %h:%p example.com

Which one should I prefer when? Is either of them faster or more efficient in some way?

Best Answer

The two settings do the same thing. The -W option was added in 2010 and is described as a “netcat mode”.

Use ssh -W if you don't need compatibility with versions of OpenBSD prior to 4.7 or with portable OpenSSH prior to 5.5 (I think). Use nc if you do need to support older versions of OpenSSH. ssh -W is preferable if available because it's marginally more efficient and doesn't require a separate utility to be installed.

Related Question