I am trying to connect to a SSH server through a proxy on CentOS 7.

I found some solutions with ProxyCommand and connect-proxy but this one is not available for CentOS 7.

I found another way with nc (nmap-ncat) and the -X option but the one installed on CentOS 7 returns an error nc: invalid option -- 'X'.

How can I connect to a SSH server through a proxy with CentOS 7?


Solution 1:

I just have encountered this problem on a Centos 7 myself. In order to connect I installed proxy-connect that is available on the epel repos.

Then, once installed, is was just a matter of finding the proper options for my case, a SOCKS5 proxy:

ssh -o ProxyCommand="connect-proxy -S proxy_ip:proxy_port %h %p" remote_user@remote_server_ip

Hope this helps.

Solution 2:

For Centos 7, which probably has ncat version 6.x installed (check with rpm -q nmap-ncat, the options are very different from ncat version 7.x.

For the nc command, instead of nc -X connect -x <proxy:port> %h %p, you need to use nc --proxy <proxy:port> %h %p

The rest is the same.

For testing, sshmyip.com is a useful site.