Created
July 2, 2018 23:58
-
-
Save petergdoyle/c302925099b53ca43a3059cfda1197b5 to your computer and use it in GitHub Desktop.
Start up a socks proxy using SSH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
local_port="9090" | |
read -e -p "Enter the local port to run the proxy on: " -i "$local_port" local_port | |
remote_host="cleverfishsoftware.com" | |
read -e -p "Enter the remote host to run the proxy from: " -i "$remote_host" remote_host | |
remote_port="22" | |
read -e -p "Enter the remote ssh port: " -i "$remote_port" remote_port | |
fork_local_process="n" | |
read -e -p "Run process in background (y/n)?": " -i "$fork_local_process" fork_local_process | |
fork_option="" | |
if [ "$fork_local_process" == "y" ]; then | |
fork_option="-f" | |
fi | |
cmd='ssh -D '$local_port' -CN '$fork_option $remote_host' -p '$remote_port | |
echo "$cmd" | |
response="y" | |
read -e -p "About to run command $cmd" -i $response response | |
if [ "$response" == 'y' ]; then | |
eval "$cmd" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment