Created
January 18, 2016 05:08
-
-
Save andrwj/0051bf118b29095665a1 to your computer and use it in GitHub Desktop.
easy connect ssh/mosh server
This file contains 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/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