Categories
notebook

Mount remote file systems over SSH

The following example is for mounting your blafis home folder as a ‘private’ media, not accessible to other local users.

1. Install SSHFS package using the following command (Ctrl+T) [needs root privileges]:

$ sudo apt-get install sshfs

2. Make the directory where the shared folder will be located, replace $USERNAME$ with your local user name.

$ sudo mkdir /media/$USERNAME$

3. Take ownership:

$ sudo chown $USERNAME$ /media/$USERNAME$

4. Make the directory where the blafis home folder will be mounted. I call it simply ‘blafis’

$ mkdir /media/$USERNAME$/blafis

5. Enable passwordless login at blafis using ssh authentification key login. Check online tutorials for this.
Usualy the authentification key is stored at /home/$USERNAME$/.ssh/id_rsa

6. Test sshfs, replace $BLAFISUSERNAME$ with your blafis user name

$ sshfs $BLAFISUSERNAME$@blafis.servers.ua.pt:/home/$BLAFISUSERNAME$ /media/$USERNAME$/blafis
$ cd /media/$USERNAME$/blafis
$ df -h .

7. Unmount the test filesystem

$ umount -f /media/$USERNAME$/blafis

8. Enable automounting at user login, changing ‘fstab’ file.

$ sudo vi /etc/fstab

9. Add the following line at the end of file. DO NOT CHANGE the other lines. May break your system.
Check if the values of UID and GID are correct.
UID: type $ id -u $USERNAME$
GID: type $ grep users /etc/group and check 3rd value.

$BLAFISUSERNAME$@blafis.servers.ua.pt:/home/$BLAFISUSERNAME$ /media/$USERNAME$/blafis fuse.sshfs _netdev,user,idmap=user,transform_symlinks,identityfile=/home/$USERNAME$/.ssh/id_rsa,default_permissions,uid=1000,gid=100 0 0
blafis_mount

10. Reboot your system.
If everything went OK, balfis mount will be available in the dashboard upon user login (see screenshot below) or via command line at the mount point /media/$USERNAME$/blafis/.