How to: Mount Remote Directories using sshfs

So, we had this lab last week, doing some hands on work on Xen. While performing a task, one of the requirements was to make the directory structure look exactly the same as the one on the remote machine. One way, was to manually change the directory contents - filenames etc. and make it look similar to that on the remote system(pathetic way ), the other was to mount it remotely(better way). Thats when I came to know about this really quick and secure way of mounting remote locations using sshfs.

Well, the same could have been done using NFS but I found sshfs way faster than all of them(in terms of setup time, I work on LAN, everything seems same in terms of speed). Seriously people, its just like a regular ssh command, as simple as logging into a system, hardly takes a few seconds. I am pretty sure at the end of this post, you all will be turning towards it in time of need, ofcoure unless you know of a better method :P.

Its very easy to work with sshfs. Since, its supported by most of the ssh servers, all you have to do is install it on the client side and run a single && simple command. Lets first install it

Install sshfs on Linux

The package sshfs is available on almost all the distros. Run the concerned command on your system.

[shredder12]$ sudo aptitude install sshfs # for Debian/Ubuntu

[root]# yum install sshfs # for Redhat/Fedora/CentOS

Now, lets say there is some directory /mnt/dir/ on the remote system user@remote and we want to mount it on our /mnt directory. This is how we do it using sshfs.

[shredder12]$ sudo sshfs user@remote:/mnt/dir /mnt

Yep! Thats all Folks! .

I used sudo because of permission issues. I hope now you all can see the power of sshfs.

2 Comments

Anon Linuxer (not verified)
September 12th, 2010 12:52 pm
The exact same syntax as scp! That's easy to remember. I'll be using it right away. Also looking forward to an osx port.
himanshu arora (not verified)
October 14th, 2010 02:44 am
nice article...:)

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.
  • Search Engines will index and follow ONLY links to allowed domains.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.