Skip to content

Instantly share code, notes, and snippets.

@augcesar
Created September 8, 2015 11:52
Show Gist options
  • Save augcesar/c4e2c37d21e26a13502f to your computer and use it in GitHub Desktop.
Save augcesar/c4e2c37d21e26a13502f to your computer and use it in GitHub Desktop.
#!/bin/bash
# [connect_proxy.sh]
### VAR ###
HOST_USER="[email protected]"
HOST_SOURCE="172.19.5.10"
PORT="9876"
PORT_SSH="22"
### VAR ###
function usage
{
echo "uso: connect_proxy.sh [-r run] [-h ajuda]"
}
function run
{
echo "..."
while (true) do
if [[ $(ss -tpa | grep $PORT | grep ssh) != *ssh* ]]; then
$(ssh -f $HOST_USER -D $HOST_SOURCE:$PORT -N -p $PORT_SSH)
fi
sleep 5
done
}
while [ "$1" != "" ]; do
case $1 in
-r | --run ) run ;;
-h | --ajuda ) usage; exit ;;
* ) ;;
esac
shift
done
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment