Skip to content

Instantly share code, notes, and snippets.

@gngdb
Created September 9, 2019 19:02
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 gngdb/9cef81bce3b37b7656695f092250ce7d to your computer and use it in GitHub Desktop.
Save gngdb/9cef81bce3b37b7656695f092250ce7d to your computer and use it in GitHub Desktop.
Script for easy mosh connections
#!/bin/bash
ALGO_IP=`ip addr | awk '
/^[0-9]+:/ {
sub(/:/,"",$2); iface=$2 }
/^[[:space:]]*inet / {
split($2, a, "/")
print iface" : "a[1]
}' | grep tun | cut -b 8- | cut -d "." -f 1-3 | sed 's/$/.1/'`
mosh --ssh="ssh -i algo.pem" ubuntu@$ALGO_IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment