sshproxysockssocks5

macOS Terminal, Connect to SSH using Socks Proxy


I have been using this command to connect Terminal to my local SOCKS5 Proxy:

export http_proxy=socks5://127.0.0.1:8070 https_proxy=socks5://127.0.0.1:8070 && curl ifconfig.me;

My IP is correct according to ifconfig.me, so port 80 and 443 work fine, but when I use SSH, I'm not connected through the proxy.

Is there a simple way around that?


Solution

  • I was able to connect ssh via shadowsocks with netcat:

     ssh -v -o 'ProxyCommand=ncat --proxy-type socks5 --proxy 127.0.0.1:1086 %h %p' -p22 username@ip
    

    You can add it to ~/.ssh/config

    Host *
         ProxyCommand=ncat --proxy-type socks5 --proxy 127.0.0.1:1086 %h %p
    

    netcat isnt avaliable in MacOS by default, you need to install:

    brew install nmap