How to mount a remote system as a drive using SSH in OS X

SharedDriveIconXBeing a unix-like system, OS X includes the SSH remote login service that can be used to administer a system from the command line. Such remote access is convenient to have, as it will allow you to change settings, manage files and folders, and otherwise use your system without needing to be right in front of it. It also communicates over an encrypted connection so you can be sure communications with your system are secured.

In addition to allowing you to log into your system and controlling it through the Terminal, the SSH protocol allows for transfer of files to and from the remote system through the SFTP (secured FTP) protocol. This is generally done with a dedicated FTP client like Cyberduck that supports the SFTP protocol, but you can also use a technology called “File System in Userspace” or FUSE, to manage this connection as a locally-mounted storage volume.

In general, to host a storage format as a mounted drive, OS X will need to have support for it coded in the OS X kernel. This is the case with Apple’s HFS+ format, and FAT32, as well as NTFS which Apple supports in read-only mode; however, FUSE provides a behind-the-scenes interface  that routes a number of storage programmable routines to the system for access as a drive-like storage medium. For instance, if you have several cloud-based storage accounts, you can write a small program (called a FUSE client or plug-in) that will interface all of these services with FUSE, and have them mount as a single volume on the system in a similar way as if you had plugged in a USB drive.

While many of the implementations of FUSE (such as combining cloud-based storage for access as a local drive) are experimental and fun, there are some exceptionally useful and well-tested uses that can be beneficial. With regards to the SSH and SFTP connection, one of the more practical uses of FUSE is to handle the SFTP connection so files on a remote system can be directly accessed in the Finder or by other programs.

  1. Download and install FUSE, followed by installing SSHFS, both of which can be obtained from the OS X FUSE site
  2. Create a folder on your Mac that you want to use as the mount point (I recommend a folder called “mount” directly within your home directory)
  3. Open the Terminal and run a command similar to the following to mount a remote folder at the new folder you would like to use as the mount point:
    sshfs username@hostname:/remote/directory/path /local/mount/point -ovolname=NAME

In this command, the username is your login ID and the hostname is the IP address, local “Bonjour” address, or other fully qualified domain name (FQDN) for your server. The /remote/directory/path is whatever folder path you would like to specify as your target (it can simply be a slash to mount your remote system’s root folder), and the /local/mount/point path is the path on your current system to the folder you want to use as the mount point. For a folder called “mount” in your home directory, this path can simply be “~/mount”. The final detail here is the “-ovolname” flag that is set to “NAME,” where you specify the name of the volume that you mount. This is optional, and if you do not specify a name, then the mounted drive will be named to represent the FUSE connection.

As you can imagine, this might be cumbersome to always do, so if you find yourself using this approach for securely accessing your remote files, then you can use the tool called “Macfusion” to store common server settings and mount them without needing to type in the command manually.

SSHFS drive mounted with FUSE in OS X

When mounted, the FUSE drive will show instead of your mount folder, and clicking it will reveal the files and folders at the remote path that you specified.

When done, you will be able to open the mounted drive on your Mac and access the files on the remote server directly. When finished, you can right-click and eject the drive as you would with any mounted volume. Finally, this approach does circumvent OS X’s default handling of drives and networked volumes, so you will not see the drive appear in your Finder sidebar and will instead have to locate it manually in your home folder or at the top-level of the filesystem.

Lastly, keep in mind that this technology has its limits. Being managed in Userspace means you have to be logged in for it to work, and then the drive will only be accessible to the account that is managing it. In addition, you might encounter limited performance and perhaps stability issues with some FUSE plugins that have not been fully tested, but overall with SSHFS and other popular options you should have a robust way to access your files.

5 thoughts on “How to mount a remote system as a drive using SSH in OS X

    1. Topher Kessler Post author

      That is another option you can use; however, it will require you to have more than one sharing service enabled. This should not be a problem, but if you prefer to keep minimal sharing services enabled then you can connect directly with SFTP and use FUSE on remote systems to mount the connection as a local drive just as you would an AFP or SMB share.

      1. Naomi D

        Topher, I have a question that I posted below. I was wondering if you could help me with that. I have an error message that pops up constantly that has the icon pictured at the beginning of this article. The error message says, “There was a problem connecting to the server “___’s Airport”. When I got this computer, I changed the name of the airport, and I think that’s the problem. What I’d like to do is figure out what keeps trying to access the airport so I can either change it to the correct airport, or delete whatever it is that is accessing it. I’m computer literate, but not to the extent that I need to be to figure this out on my own.

  1. Naomi D

    I keep getting an error message with the icon you have pictured at the start of this article saying that it can’t find an airport. When I renamed my computer and airports, I started getting this message. I’m guessing that this program is looking for something that doesn’t exist. Unfortunately, it pops up constantly. The only thing I can do is keep the box open in the lower part of my screen. I’ve done a google image search for this icon, and this is the only place I can find it. I’m definitely a Mac newbie, and I’m sorry to say that I don’t even understand this article (sorry!). Can you help me figure out how to get into this program and stop it from looking for an airport that doesn’t exist anymore? Thanks!

  2. keramzyt

    I’ve got this message on the terminal, how to solve it?

    “-bash: sshfs: command not found”


Leave a Reply to Michael Schmitt Cancel reply