Skip to content

Instantly share code, notes, and snippets.

@jangxx
Last active March 3, 2019 12:42
Show Gist options
  • Save jangxx/81b44f70b4951cf3fefb9912f20face1 to your computer and use it in GitHub Desktop.
Save jangxx/81b44f70b4951cf3fefb9912f20face1 to your computer and use it in GitHub Desktop.
Easy sshfs mount script for OSX
#!/bin/bash
if [ -z $1 ]; then
echo "Usage: sshfs_ez user@address [port]";
exit
fi
PORT=22
if [ ! -z $2 ]; then PORT=$2; fi
mount_count=0
mount_base="/Volumes/sshfs"
mount_point="$mount_base$mount_count"
#try to find a suitable mount point
while [ -a $mount_point ]; do
mount_count=$(($mount_count + 1));
mount_point="$mount_base$mount_count"
done
echo "Enter admin password first, then authenticate against the ssh server"
#create said mount point
sudo mkdir $mount_point
sudo chown $USER $mount_point
#mount sftp
sshfs "$1:/" $mount_point -p $PORT -oauto_cache,reconnect,defer_permissions,negative_vncache,allow_other,volname=$1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment