[HowTo] Use SSHFS to mount remote directories via SSH

SSHFS command
I was using scp to copy from and to my VPS since a while now. It worked quite well. But that seemed way too much work for lazyhead like me. So I started looking for alternatives. I didn’t want to configure FTP server for this (again, too lazy for that). I came across SSHFS which is exactly what I wanted. You can mount remote directories on local machine via SSH. Exactly what I wanted – you don’t need to install anything on remote machine. SSH server is all it requires.

  • To install SSHFS on Ubuntu:
    sudo apt-get install sshfs

    For other distributions, check out sshfs homepage.

  • You need to install yourself into group ‘fuse’:
    sudo gpasswd -a $USER fuse
  • Create a mountpoint where you want to mount the root directory and run sshfs:
    mkdir ~/my_vps
    sshfs -o idmap=user root@myvps.com:/home ~/my_vps

This will mount the /home directory on your remote server to ~/my_vps. Since SSHFS is based on Fuse, the mounted directories work just like normal directories and you can use these directories directly in applications like any other directory.

Automounting on startup:

Put the following in your /etc/fstab:

sshfs#root@myvps.com:/ /home/dpac/my_vps fuse defaults,idmap=user 0 0

Makes file management on remote servers a hell lot easier.

Cheers!