Posted by chantra on March 30th, 2006
SSH is a protocol to securely connect to a remote host. In previous article we have seen how-to connect to a remote database through a secured tunnel.
It is possible to transfer files using ssh protocol by using the scp command, it would be neat to be able to mount a remote directory through a secure protocol, so this way, all the transferred data will be encrypted.
A combination of FUSE(a userspace filesystem framework) and SSHFS(SSH FileSystem) will do the job. FUSE is a
Here is the case, let's say I have an ssh access on a computer out of my lan network. I would like to be able to easily access those datas without having to use scp nor a specific software to transfert those datas, basically, I would like those datas to be accessible just like if there were on my local computer.
The tools we are going to need are: FUSE and SSHFS. So first of all, install them.
tester@laptop:~$sudo apt-get install sshfs fuse-utils
As we want to be able to mount the filesystem as user tester, we need to add tester to group fuse. Type:
tester@laptop:~$ sudo usermod -G `groups tester | cut -f2 -d':' | tr -s ' ' , | cut -f2- -d,`,fuse tester
This command helps you to get the groups user tester belongs to, we clean the output, translate the ' ' (spaces) to ',' (commas) and add the group fuse at the end.
Note that if your system has the adduser command, you can use the following syntax:
tester@laptop:~$sudo adduser tester fuse
In order to have your user added to the new group, you will have to log out and then log back in
We also need to include the fuse kernel module:
tester@laptop:~$sudo modprobe fuse
In order to include this module at boot time, you need to edit /etc/modules and add fuse to the list.
Now, let's create a directory where we want to mount the file system:
Now it is time to mount the whole thing:
tester@laptop:~$sshfs my-remote-user@my-remote-host:/home/my-remote-user remotefs/
Here you are, you can now access your remote datas as if there were on your local filesystem, awesome .
If you want to unmount this filesystem, use:
tester@laptop:~$fusermount -u remotefs/