Last active
February 15, 2016 21:07
-
-
Save guyhughes/484fba05482028163e1e to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
| set -e | |
| export SCRIPTNAME="$0" | |
| while [ $# -gt 0 ]; do | |
| case "$1" in | |
| -s|--start) | |
| if [ "$(ssh-add -l 2>/dev/null | wc -l)" -lt 1 ]; then | |
| echo "fatal: ssh-agent must be available with identities loaded" | |
| exit 1 | |
| fi | |
| set -x | |
| ssh -TfL 2022:vmicron02:22 cu sleep 30 >/dev/null 2>/dev/null | |
| sudo -E bash << EOHF | |
| ssh -NTfL 443:134.117.31.38:443 [email protected] -p 2022 >/dev/null 2>/dev/null | |
| iptables -t nat -A OUTPUT -p all -d 134.117.31.38 -j DNAT --to-destination 127.0.0.1 >/dev/null 2>/dev/null | |
| EOHF | |
| set +x | |
| ;; | |
| -k|--kill) | |
| set -x | |
| # kill -9 "$(cat $SCRIPTNAME.tun1)" | |
| # sudo -E kill -9 "$(cat $0.tun2)" | |
| sudo iptables -t nat --flush | |
| # rm "$SCRIPTNAME.tun1" "$SCRIPTNAME.tun2" | |
| echo 'You may wish to kill the ssh tunnels with pkill -x ssh' | |
| set +x | |
| ;; | |
| -l|--list) | |
| sudo iptables -t nat -L | |
| ;; | |
| *) | |
| echo "Invalid parameter: $1" | |
| exit 1 | |
| ;; | |
| esac | |
| shift | |
| done |
This file contains hidden or 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
| Host cu | |
| HostName access.scs.carleton.ca | |
| User guyhughes | |
| IdentityFile ~/.ssh/id_rsa | |
| Cipher arcfour |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment