Skip to content

Instantly share code, notes, and snippets.

@pooyagolchian
Last active May 30, 2020 20:07
Show Gist options
  • Save pooyagolchian/520ee77f22836d92b483f3f8827f8767 to your computer and use it in GitHub Desktop.
Save pooyagolchian/520ee77f22836d92b483f3f8827f8767 to your computer and use it in GitHub Desktop.
Ssh tunnle on macos and set socks5 proxy (Tunnle over SSH)
#!/bin/sh
NET_SERVICE="Wi-Fi"
PORT=1080
[email protected]
PID=`pgrep -f ${PORT}`
if [ "$EUID" -ne 0 ]
then echo "Please run as root!"
exit
fi
if pgrep -f ${PORT} >/dev/null
then
echo "WELCOME TO POOR MAN'S VPN"
echo "Ssh process in running with pid" $PID
kill -9 $PID
echo "Kill ssh process with PID" $PID
else
echo "Ssh process not found"
fi
ssh -D ${PORT} -f -C -q -N ${SERVER}
echo "Connect to server"
networksetup -setsocksfirewallproxy ${NET_SERVICE} 127.0.0.1 ${PORT}
networksetup -setsocksfirewallproxystate ${NET_SERVICE} on
PID=`pgrep -f ${PORT}`
echo "Ssh runs on PORT "${PORT}" and PID "${PID}". socks proxy set on Wi-Fi"
echo "For turn off socks5 proxy run command -> sudo kill -9 "${PID}"; networksetup -setsocksfirewallproxystate "${NET_SERVICE}" off"
echo "Change proxychain4 socks5 port sudo sed 's/foor/bar/g' /etc/proxychains.conf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment