Created
July 9, 2015 07:45
-
-
Save Sketches-su/33ff9704556b6c90ae35 to your computer and use it in GitHub Desktop.
Shell script for mounting remote dir by sshfs and obtaining SSH console
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 [ -z "$1" ]; then | |
echo No user@host specified! | |
exit 1 | |
fi | |
if [[ ! "$1" =~ ^[^@:]+@[^@:]+:[^@:]+$ ]]; then | |
echo Invalid user@host! | |
exit 2 | |
fi | |
mntdir="$HOME/remote/`echo "$1" | cut -d':' -f1 | sed -e 's#@#.at.#'`" | |
if [ `cat /etc/mtab | grep "$mntdir" | wc -l` -gt 0 ]; then | |
echo Point is already mounted! | |
exit 3 | |
fi | |
[ ! -d "$mntdir" ] && mkdir "$mntdir" | |
sshfs "$1" "$mntdir" | |
ssh "`echo "$1" | cut -d':' -f1`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment