Skip to content

Instantly share code, notes, and snippets.

@andrwj
Created January 18, 2016 05:08
Show Gist options
  • Save andrwj/0051bf118b29095665a1 to your computer and use it in GitHub Desktop.
Save andrwj/0051bf118b29095665a1 to your computer and use it in GitHub Desktop.
easy connect ssh/mosh server
#!/bin/bash
# if $0 looks like id@domain
# then login as id
# else
# login as default user
default_uid="root"
script="`basename $0`"
echo "$script" | grep -q '@'
if [[ $? -eq 0 ]]; then
# type uid@domain
IFS='@' read -a tokens <<< "${script}"
uid=${tokens[0]}
host=${tokens[1]}
else
uid=${default_uid}
host=$script
fi
mosh ${uid}@${host}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment