This post will show you how to mount a remote ssh filesystem as a ‘drive’ in osx using a bash script, osxfuse and brew. There are a few ways to go about this, all of them require a bit of setup and tweaking, But I found this to be the easiest way – once its setup you don’t need to do anything, and you have a command to re-mount the drive if need be.
1) you need to install osxfuse if you dont already have it [ http://osxfuse.github.io ]
2) you also need to install homebrew [ http://brew.sh ]
3) once you have brew you need to install ssh-copy-id and sshfs from homebrew
brew install sshfs ssh-copy-id
4) setup keyless authentication [ /ssh-with-keys-for-authentication ]
To do this we will create a script to mount the drive for us (we can run this script at any time to mount the drive – eg if you get a disconnection just re-run this script and the drive will re-mount)
# I made this in my ~/bin folder - remember to chmod +x the file after you make it # give your drive a nice name and location mkdir /Volumes/SomeNiceName #mount it sshfs -o reconnect -o volname=SomeNiceName -o IdentityFile=~/.ssh/id_rsa remotehost.com:/path/to/wherever /Volumes/SomeNiceName
The options used:
-o reconnect — this will re-mount the drive after you suspend your computer, etc
-o volname=SomeNiceName — this will show ‘SomeNiceName’ as the label of your drive
-o IdentityFile — this is the location of your ssh key so you dont have to enter a password all the time
You can now run this script in a terminal to mount your drive
you’ll see a nice little drive icon on your desktop which you can use in finder like any other folder :D
The easiest way to do this is via your startup items – that way every time you log in your drive will mount:
No related posts.