Tunneling an ssh session through a SOCKS5 proxy (e.g. using Tor) should be possible by adding the following to your
/etc/ssh/ssh_config file:
Host *.example.com
CheckHostIP no
Compression yes
Protocol 2
ProxyCommand ncat --nodns --proxy-type socks5 --proxy 127.0.0.1:9050 %h %pUnfortunately, RHEL7/CentOS 7 ships with a rather antiquated version of nmap-ncat (a modern replacement for the now unmaintained BSD netcat) and this version only supports socks4.
Trying to use socks4 is similar to using no proxy at all, it fails with the following rather cryptic error message:
get_sock_port: getnameinfo NI_NUMERICSERV failed: ai_family not supportedSolution: Uninstall the useless version of nmap-ncat:
yum erase nmap-ncatDownload the newest RPM from
https://nmap.org/download.htmlInstall it. Example:
yum localinstall ncat-7.30-1.x86_64.rpmFix your
/etc/ssh/ssh_config as shown above.