Mounting Remote Filesystems with SSHFS


If you work with Linux servers, you’ve probably used ftp or (better yet) sftp or scp to download files from the remote server to your local PC. However, if you have to work with remote files a lot, you may want to mount the remote file system in some way. Usually this is done through NFS or Samba, but setting that up can be difficult, and if you don’t happen to have root access on the remote server, you may not be able to do it all.

I’ve starting using another method recently for accessing remote file systems from my Linux PC: SSHFS. SSHFS is just what it sounds like, a tool to mount remote File Systems via SSH. The big advantage to sshfs is you don’t need to do anything on the remote server to use it; if you have SSH access to that server, you can immediately start using sshfs.

Here’s a site that can tell you more about how to setup and use sshfs: http://www.debianadmin.com/mount-a-remote-file-system-through-ssh-using-sshfs.html

Basically the process is very simple.
1. Install sshfs on your Linux PC:
sudo apt-get update
sudo apt-get install sshfs
2. Create a local mountpoint for the remote filesystem, e.g.:
sudo mkdir /media/Remote or sudo mkdir /mnt/Remote
3. Make sure you own that directory:
sudo chown -R you:you /media/Remote
4. Mount the remote file system with sshfs:
sshfs you@remote_server: /media/Remote

That’s it. You can now access your home directory on the remote server as if it were a local file system. If you only want to access a specific remote directory, you can include the path to that in the sshfs command, e.g.
sshfs you@remote_server:/path/to/directory /media/Remote

When you want to disconnect the remote filesystem, you just enter:
fusermount -u /media/Remote

The mountpoint you created is still there, so the next time you only have to enter the sshfs command to reconnect. (SSHFS is based on FUSE, which is why you use fusermount to dismount the remote filesystem.)

Another great advantage to sshfs is it’s much faster than Samba. I have my digital music collection loaded on my home file server, and I tried to play music on my desktop by accessing the Samba share, but the transfer rate was too slow, and the playback was very choppy. However, playing remote music files through sshfs is perfectly smooth. I did a quick and dirty test, and transferring a 1.4G directory through Samba (on my home network) took 59 seconds. Using sshfs, it took 22 seconds, more than twice as fast as Samba.

For you Windows users, there is an implementation of sshfs for Windows as well: http://ubuntuforums.org/showthread.php?t=1027820. (Disclaimer: I use Windows as little possible, and not tried implementing sshfs on a Windows system, so I have no idea how well this works.)

In summary, sshfs is a great little tool for accessing remote file systems, that doesn’t require any extra work on the server. Give it a try.

– Larry

Leave a comment

Your email address will not be published. Required fields are marked *

Are you human? * Time limit is exhausted. Please reload CAPTCHA.