Skip to content

Instantly share code, notes, and snippets.

@ChrisBuchholz
Created March 10, 2015 14:02
Show Gist options
  • Save ChrisBuchholz/ad19fc0d289f80a9c3bb to your computer and use it in GitHub Desktop.
Save ChrisBuchholz/ad19fc0d289f80a9c3bb to your computer and use it in GitHub Desktop.
mount a remote folder over ssh
rmount () {
#
# requires osxfuse, sshfs and ssh-copy-id and that you have keyless
# ssh login set up between you and the remote
#
# usage:
# rmount 99.99.99.99 /some/path
#
# if you leave out the path it defaults to ./ (home folder)
#
REMOTE_HOST=$1
REMOTE_PATH=$2
MOUNT_PATH=/Volumes/$REMOTE_HOST
if [ -z "$2" ]; then
REMOTE_PATH=./
fi
[ -d $MOUNT_PATH ] || mkdir $MOUNT_PATH
sshfs -o reconnect -o volname=$REMOTE_HOST -o IdentityFile=~/.ssh/id_rsa $REMOTE_HOST:$REMOTE_PATH $MOUNT_PATH && open $MOUNT_PATH
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment