Using SSHFS

Printer-friendly versionPrinter-friendly versionAlthough it's relatively simple, I thought I'd write a brief article on the use of sshfs, because it's such a helpful tool. First, you'll need to have sshfs and fuse installed. You can get them here(sshfs) and here(fuse). The server (remote) side doesn't need anything but sshd (ssh server) installed. The beauty of the whole arrangement is that sshfs is really just a kind of wrapper around ssh/sftp, so the server doesn't even need to know about any permissions other than the standard ssh login. You can mount any path from the server that you have access to via ssh. Using sshfs from the command line is really easy. To mount a filesystem, you'll want to do so as your standard user (not root). Simply do:
sshfs user@host: <mountpoint>
and to unmount:
fusermount -u <mountpoint>
mounting through fstab is a bit trickier. The fstab line looks like:
sshfs#USER@<remote host>:<remote path> <mount point> fuse <sshfs_options> 0 0
thus, a sample for root to mount on bootup, using some common options might be:
sshfs#user@host:  /mnt/user_remotehome  fuse sshfs_sync,no_readahead,port=22,allow_other   0  0
This would mount a user's remote home directory on /mnt/user_remotehome, using no user translation at all, just standard uid's, but allowing people (users) other than 'root'(who did the mounting on boot) to access it. Without the 'noauto' directive, this would require that either you enter the password for ssh during your machine's boot (very inconvenient), or setup your root's ssh key on your remote machine in that user's account. (perhaps not desirable). A line that would be for a user to do his/her own mounting, and not automatically mount as root on bootup might look more like:
sshfs#user@host:  /mnt/user_remotehome  fuse sshfs_sync,no_readahead,port=22,user,noauto   0  0
You have to take the allow_other option out, or set 'user_allow_other' in /etc/fuse.conf. Note that to unmount, you have to be root to use the 'umount' command to unmount the filesystem. This is no problem if you leave it mounted until your machine shuts down, but if you'd like to unmount you'll either have to be root, sudo or use the 'fusermount -u' command. There are man options to explore, so I'd have a look at the following manpages:

Search Engine Optimization