dcsimg

Cool User File Systems, Part 1: SSHFS

Userspace file systems are one of the coolest storage options in Linux. They allow really creative file systems to be developed without having to go through the kernel gauntlet. This article presents one of them, SSHFS, that allows you to remotely mount a file system using ssh (sftp).

In keeping with our current theme of cool user-space file systems, this article examines the first user-space file system I ever used: SSHFS. SSHFS has a client that can mount and interact with a remote file system as though the file system were local. It uses sftp so it’s as secure as sftp is (I’m not a security expert so I can’t comment on the security of ssh). SSHFS can be very handy for working with remote file systems instead of copying files back and forth from remote systems or having to worry about a shared file system. People have even used it for making backups.

This article is just a quick overview of SSHFS because there are a very large number of SSHFS howto’s for various Linux distributions (Google is your friend). While the basics of installing and running SSHFS are covered here, the various howto’s are much more comprehensive.

Installing SSHFS

Installing SSHFS is actually a pretty easy affair. The first step for any FUSE based file system is to make sure that FUSE itself is included in the kernel or as a module. Many distributions already come with FUSE pre-built in the kernel. There are multiple ways to check if FUSE has been built. For example, on my Ubuntu 8.10 laptop I can look for the module in the latest kernel:

laytonjb@laytonjb-laptop:~$ ls -lsa /lib/modules/2.6.27-17-generic/kernel/fs/fuse
total 96
 4 drwxr-xr-x  2 root root  4096 2010-03-21 16:42 .
 4 drwxr-xr-x 53 root root  4096 2010-03-21 16:42 ..
88 -rw-r--r--  1 root root 83200 2010-03-11 23:57 fuse.ko


So you can see that FUSE has been built as a module (.ko) for the kernel since the file exists. You can also check if the kernel module is loaded by the kernel.

laytonjb@laytonjb-laptop:~$ /sbin/lsmod | grep -i fuse
fuse                   60956  3


These are just two ways you can check if FUSE has been built for your kernel. Another way is to install the kernel source for your distribution and then look at the kernel configuration, “.config”, in the kernel source directory and you can check if FUSE has been added to the kernel itself or as a module.

If you need to build the FUSE module for your running system you will need to follow the directions on the FUSE homepage. But basically it consists of the common steps one uses to build almost any open-source package.

$ ./configure
$ make
$ make install


These steps build a kernel module for the currently running kernel but only if you have the source for your latest kernel and the “configure” script can find it (be sure to do the last step, “make install”, as root).

Once FUSE is installed and working the next step is to install SSHFS. You can install it using the package management tools for your distribution or you can build it from source. It too has the same simple build steps of many open-source applications.

$ ./configure
$ make
$ make install


where the last step is performed as root. Just be sure to read the SSHFS page for package prerequisites. In particular for the recent versions (as of the writing of this article), you will need glib2.

As an example for this article, I will be using SSHFS on my laptop that is running Ubuntu 8.10 and a remote file system. For Ubuntu 8.10, you will need to install glib2 as well as sshfs 2.02-2 (the latest version from the SSHFS homepage is 2.2) which is easily accomplished using the Synaptic package manager.

At this point FUSE and SSHFS should be installed and we’re ready to use SSHFS.

Using SSHFS

I’m going to use a remote file system I have on a system that is not under my control (it is administered by someone else) that I can access only via ssh (and scp/sftp). The SSHFS webpage recommends not mounting the remote file system as root but instead as a user. So I will mount the remote file system in a directory (mount point) in my home account on the laptop. In particular, I will mount the file system as SSHFS_TEST on my laptop.

The command to mount the remote file system is simple,

$ sshfs remote_system: mount_point


where remote_system is the name of the remote system. If you have a different login on the remote system compared to your local systems then you need to use “remote_system” in the form, “user@remote_system”.

For this particular example, the screen shot to mount the remote system is below.

laytonjb@laytonjb-laptop:~$ sshfs [system]:[home_root]/laytonjb /home/laytonjb/SSHFS_TEST
Password:


I have removed the details to protect the innocent. The term, [system], is the name of the system, and [home_root] is the full root directory to my account on the remote system except for my login name. The last term, “/home/laytonjb/SSHFS_TEST”, is the local mount point. Note that you may have to give your password when performing the mount but after that you should not have to use your password.

If you have problems with SSHFS, then you may have problems with ssh. If you can’t mount the file system or if you get an error, you can check the problem(s) by just using ssh to the remote system. You should also check scp and sftp to make sure they are working.

Now that the file system is mounted, let’s just do a simple “ls” to check that we can access the data.

laytonjb@laytonjb-laptop:~$ ls -s SSHFS_TEST
total 44
24 configure.wrf   4 example_woodcrest  16 Makefile


The remote system has just a few files, but I can easily access them by any application that is POSIX compliant. For example, I could use “vi” to edit the file or I could use the normal command line tools, “cp”, “ls”, “mv”, “rm”, etc., to manipulate the files.

As you can see, it’s pretty easy to use SSHFS. Once it’s installed mounting remote file systems is fairly easy for any user to accomplish using their own home account.

There are a huge number of articles describing how to setup SSHFS and how it can be used. Remember that SSHFS is based on ssh so there are a number of articles on how to configure ssh to not require passwords during mount. For example, there is a good article on how to configure PAM (Pluggable Authentication Modules) and SSHFS to not use ssh passwords.

Perhaps somewhat surprisingly there are a number of article about using SSHFS as part of a backup process. For example, this article talks about how to automate backups using SSHFS.

Another group of articles is how to use SSHFS with Windows for mounting Windows volumes. For example, this article explains how to mount remote Windows volumes on Linux desktops.

But one thing to remember about SSHFS is that it uses ssh underneath so do not expect good performance from it. For example, it can be appealing to replace nfs with SSHFS since users can mount remote file systems very easily, perhaps even in HPC systems. But ssh will have to encrypt the data before sending it and then decrypt it on the receiving side, using CPU cycles and reducing throughput. But if performance is perhaps not the primary motivation for SSHFS then it is definitely something worth considering.

Summary

SSHFS was the first userspace file system I used. Years ago it allowed me to mount remote file systems on my desktop so I could easily copy, edit, and manipulate the files. It was a wonderful tool that made my life easier by far and I still use it today.

SSHFS is very easy to configure once FUSE is configured and installed. Most distributions today already have FUSE configured and installed so that usually isn’t a problem. But if you build your own kernels like I tend to do, you will need to make sure that FUSE is configured.

SSHFS is just one wonderful example of a user-space file system based on FUSE. If you have a remote file system you need to access then SSHFS is the way to go.

Comments on "Cool User File Systems, Part 1: SSHFS"

Every when in a whilst we decide on blogs that we read. Listed beneath are the latest internet sites that we decide on.

One of our guests a short while ago proposed the following website.

One of our guests not too long ago recommended the following website.

We like to honor quite a few other world wide web websites around the internet, even when they aren?t linked to us, by linking to them. Under are some webpages really worth checking out.

Usually posts some quite fascinating stuff like this. If you are new to this site.

That could be the end of this article. Right here you?ll uncover some web pages that we consider you will appreciate, just click the hyperlinks.

That would be the end of this post. Here you will find some web-sites that we feel you?ll enjoy, just click the hyperlinks.

We prefer to honor numerous other world wide web sites around the net, even when they aren?t linked to us, by linking to them. Under are some webpages really worth checking out.

Say, you got a nice blog article.Really looking forward to read more. Really Great.

We came across a cool internet site which you may possibly take pleasure in. Take a appear if you want.

We like to honor many other world wide web websites around the web, even though they aren?t linked to us, by linking to them. Under are some webpages worth checking out.

Really appreciate you sharing this post.Really looking forward to read more.

Always a huge fan of linking to bloggers that I appreciate but do not get quite a bit of link enjoy from.

Enjoyed every bit of your blog post.Really looking forward to read more. Keep writing.

Sites of interest we have a link to.

The time to study or check out the content or sites we have linked to beneath.

Check beneath, are some completely unrelated internet sites to ours, nonetheless, they’re most trustworthy sources that we use.

Just beneath, are numerous absolutely not related sites to ours, even so, they’re surely really worth going over.

Wonderful story, reckoned we could combine a number of unrelated information, nonetheless genuinely really worth taking a search, whoa did one particular discover about Mid East has got much more problerms as well.

Please go to the sites we comply with, including this a single, as it represents our picks in the web.

That is the finish of this article. Here you will discover some web sites that we consider you will enjoy, just click the hyperlinks.

Wonderful story, reckoned we could combine a few unrelated data, nevertheless truly worth taking a appear, whoa did a single discover about Mid East has got extra problerms at the same time.

Appreciate you sharing, great article post.Really thank you! Cool.

Below you will uncover the link to some web sites that we feel you must visit.

Here are some links to internet sites that we link to because we believe they’re really worth visiting.

You really make it seem so easy with your presentation but I find
this topic to be actually something that I think I would never understand.
It seems too complicated and extremely broad for me.
I’m looking forward for your next post, I will try to get the
hang of it!

Every as soon as in a even though we select blogs that we study. Listed below would be the newest websites that we pick.

Just beneath, are numerous entirely not related web-sites to ours, even so, they are surely really worth going over.

Usually posts some extremely intriguing stuff like this. If you are new to this site.

That would be the end of this report. Here you will uncover some internet sites that we believe you will enjoy, just click the hyperlinks.

Here is an excellent Blog You may Find Interesting that we encourage you to visit.

The time to read or check out the content or web-sites we’ve linked to below.

We like to honor several other world-wide-web internet sites around the internet, even when they aren?t linked to us, by linking to them. Beneath are some webpages worth checking out.

We came across a cool web page that you may well appreciate. Take a look should you want.

The info mentioned within the article are a number of the ideal offered.

Every the moment inside a though we opt for blogs that we study. Listed beneath are the most current web pages that we opt for.

Always a major fan of linking to bloggers that I love but really don’t get a whole lot of link adore from.

Below you?ll obtain the link to some sites that we assume you must visit.

Although websites we backlink to beneath are considerably not related to ours, we feel they’re in fact really worth a go by, so have a look.

zdrLMB iodlceuzgsdh, [url=http://begsrfqpuxap.com/]begsrfqpuxap[/url], [link=http://pcqsoeemconh.com/]pcqsoeemconh[/link], http://hzlitaogryhc.com/

The data mentioned inside the report are some of the best readily available.

Sites of interest we’ve a link to.

Below you will find the link to some web-sites that we consider you need to visit.

Check beneath, are some totally unrelated internet sites to ours, even so, they are most trustworthy sources that we use.

Enjoyed examining this, very good stuff, regards. “I will do my best. That is all I can do. I ask for your help-and God’s.” by Lyndon B. Johnson.

Please visit the internet sites we comply with, such as this 1, as it represents our picks from the web.

Every once inside a though we choose blogs that we study. Listed beneath would be the newest web-sites that we select.

Here are a number of the websites we suggest for our visitors.

Every once inside a though we choose blogs that we read. Listed beneath would be the most recent sites that we pick out.

That would be the finish of this write-up. Right here you will find some web-sites that we believe you will enjoy, just click the links.

Leave a Reply