#!/bin/bash # This program will start a new ssh SOCKS tunnel to allow you to use # another server as a secure proxy. PORT=3333 USER=gmethvin HOST=unix.andrew.cmu.edu # use these settings if using tsocks # /etc/tsocks.conf: # server = 127.0.0.1 # server_port = $PORT # use a pidfile so we can kill the process later PIDFILE=$HOME/.proxify.pid # kill any existing process if [ -f $PIDFILE ]; then PID=$(cat $PIDFILE) if [ -e /proc/${PID} ]; then kill $PID fi rm $PIDFILE fi # unless we got the -k flag, start up the proxy if [ "$1" == "-k" ]; then exit 0 fi COMMAND="ssh -fND ${PORT} ${USER}@${HOST}" $COMMAND || exit 1 PID=$(ps x | grep "$COMMAND" | awk '{ print $1 }' | head -1) echo $PID > $PIDFILE