Recently, I wanted to find a simple way of mounting a remote Linux file system from my Macintosh laptop. And by “simple,” I wanted the procedure to consist of mostly downloading and installing a tool, running a command, and not having to delve too deeply into editing configuration files. Fortunately, I was able to figure this out without too much trouble, and thought I would record my experience here. The procedure involves two applications, FUSE For OS X and SSHFS, both of which can be found on the FUSE for OS X web site. FUSE for OS X is a library/framework for Mac OS X developers to establish remote connections; SSHFS is an application built upon the FUSE framework.
First, let’s establish some terminology. We’ll simply refer to the remote server that I wanted to connect to as the “Linux server” (at the domain “remoteserver”) and define my local machine as simply “my laptop.” We’ll call the file directory that I wanted to access on the Linux server as “/webapps”. In essence, I wanted to be able to access the folder “/webapps” on the Linux server as if it were a folder sitting on my laptop.
I’ll also note that I had already set up my SSH keys on my laptop and the Linux server. That needs to be accomplished before anything else. If you need guidance on that, here’s a simple tutorial.
After SSH had been set up:
- I downloaded the latest version of FUSE for OS X at the FUSE for OS X web site.
- I installed FUSE for OS X on my laptop by double-clicking the disk image, then double-clicking on the installation package. There is pretty standard Mac OS X stuff; it went without a hitch.
- I downloaded the latest version of SSHFS for OS X at the FUSE for OS X web site.
- I installed SSHFS by double-clicking on the downloaded file. I ran into an issue here where Mac OS X refused to install the package because SSHFS comes from an “unidentified developer.” To get around this, you need to override the Gatekeeper in Mac OS X, which can be as simple as right-clicking on the package and selecting “Open” from the context menu.
- Both FUSE for OS X and SSFHS were now installed.
- Next, I needed to create a new folder on my laptop which would serve as the mount point. Let’s call that folder “~/mountpoint.”
- Now, it was a matter of learning how to invoke the appropriate command to have my laptop mount the Linux server. The command I used was:
sshfs -p 22 username@remoteserver:/webapps/ ~/mountpoint -oauto_cache,reconnect,defer_permissions,noappledouble,negative_vncache,volname=myVolName
Using the above steps, I was able to successfully mount the Linux server. Unmounting is a piece of cake:
umount ~/mountpoint
Additional notes:
The SSHFS command used to mount the remote server is lengthy; indeed, filled to the brim with arguments that I cut and pasted. If you would like to know what each argument does, there is a helpful guide that describes them.
Thank you very much!
Simple and effective 🙂 works like a charm.
Thank you! After spending several hours and many failed attempts, I came across your well written article, and it worked first time.
Great thanks from me as well.
It worked perfect! before using the arguments my mountpoint folder got hidden and it did not work. It was really helpful!
My mountpoint got hidden before using the arguments too. After using the arguments, `cd` produces “error retrieving current directory: getcwd: cannot access parent directories: No such file or directory”
Finally got a working solution,
Thanks !!
one gotcha, don’t try to install osxfuse using brew cask! I was unable to see the mounted folder until i removed the brew cask version and used the installer.
sshfs is fine with brew install sshfs
also if you are trying to connect securely to ec2 with a .pem file, add IdentityFile parameter to point to your .pem file
sshfs -p 22 bitnami@_EC_IP_ADDRESS_:/home/bitnami ~/mountpoint -oauto_cache,reconnect,defer_permissions,noappledouble,negative_vncache,IdentityFile=~/.ssh/aws-test.pem
Needed this to mount Linux Server of my University and it worked on the first try! Big Thanks and Thumbs up!
What does the “volname=myVolume” parameter do? I got it to work without that but not sure if it helps something I’m unaware of.
Thank you