Skip to content

Instantly share code, notes, and snippets.

@Zsoldier
Last active September 27, 2019 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zsoldier/bfea75edd9de4d9bb0bb1e49afb7a192 to your computer and use it in GitHub Desktop.
Save Zsoldier/bfea75edd9de4d9bb0bb1e49afb7a192 to your computer and use it in GitHub Desktop.
Bash Function example calling several terminal windows in MacOS using AppleScript to launch sshuttle sessions.
#First argument defines last IP octet for 2nd and 3rd commands.
#Second argument defines an additional subnet you want to proxy for the last sshuttle connection.
crazystuffhere(){
echo -n Password:
read -s something
echo "Connecting to 1st Jumpbox 192.168.5.50 and proxying IP 192.168.10.50 through it."
osascript -e "tell app \"Terminal\"
do script \"sshuttle -r 192.168.5.50 192.168.10.50\"
delay 2
end tell"
echo "Connecting to 2nd Jumpbox 192.168.10.50 and proxying IP 192.168.20.$1 through it."
osascript -e "tell app \"Terminal\"
do script \"sshuttle -r username@192.168.10.50 192.168.20.$1\"
delay 2
do script \"$something\" in window 1
end tell"
echo "Waiting 5 Seconds"
Sleep 5
echo "Connecting to 3rd Jumpbox 192.168.20.$1 and proxying IP subnet 192.168.50.0/24 and $2 through it."
osascript -e "tell app \"Terminal\"
do script \"sshuttle -r username@192.168.20.$1 192.168.50.0/24 $2\"
delay 2
do script \"$something\" in window 1
end tell"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment