wiki'd

by JoKeru

Use SSHFS to mount remote file systems over SSH

If you need a quick solution to "attach" a remote directory to your local server, SSHFS (Secure SHell FileSystem) is the answer. On the local computer, the remote share is mounted using FUSE (Filesystem in Userspace) kernel module.

[cc lang='bash']
# install
\$ apt-get install sshfs -y
# check
\$ lsmod | grep fuse
fuse 50844 1

# mount
\$ mkdir /mnt/remote
\$ sshfs root@10.20.30.40:/ /mnt/remote
# check
\$ mount | tail -1
root@10.20.30.40:/ on /mnt/remote type fuse.sshfs (rw,nosuid,nodev,max_read=65536)
# unmount
\$ umount /mnt/remote
# or
\$ fusermount -u /mnt/remote
[/cc]
If you need this available at boot time, you have to use ssh key authorization.

If you want to have this setup for a non-root account (local user - wiki, remote user - miki), there are additional steps to follow:
[cc lang='bash']
# add user to the 'fuse' group
\$ adduser wiki fuse
\$ su - wiki
# mount
\$ mkdir miki-logs
\$ sshfs -o idmap=user miki@10.20.30.40:/home/miki/logs /home/wiki/miki-logs
# -o idmap=user makes that it does not matter if the local and the remote system use different user IDs
# files owned by the remote user are also owned by the local user
# if you don't use this, you might get permission problems
[/cc]

more details: http://www.debianadmin.com/mount-a-remote-file-system-through-ssh-using-sshfs.html

Comments