Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.