Archive for the ‘Tips and tricks’ Category

Secure remote folders with fuse and sshfs

Thursday, July 6th, 2006

Install the SSH filesystem rpm called sshfs:


[root@server ~]# yum install sshfs

Now add the users to the fuse group that are allowed to use this neat trick. In this example I’ll add myself to the fuse group:


[root@server ~]# usermod -G fuse patrick

Load the fuse module:


[root@server ~]# modprobe -v fuse

Make the directory where you want to mount the remore folder using sshfs:


[root@server ~]# mkdir /home/patrick/remotefolder

Mount the remotefolder:


[root@server ~]# sshfs me@server:/localfolder /home/patrick/remotefolder

You can now work transparantly in the /home/patrick/remotefolder. When you are done and want to unmount the folder all you need to do is:


[root@server ~]# fusermount -u /home/patrick/remotefolder

You can also add the remotefolder to /etc/fstab:


sshfs#me@server:/localfolder /home/patrick/remote_folder/ fuse defaults,noauto 0 0

The fuse module should be loaded automagically. If it doesn’t load it manually with:


[root@server ~]# modprobe -v fuse

Preventing the accidental rm -rf /

Thursday, July 6th, 2006

Eons ago when I started to explore Linux and F/OSS as an enthousiastic newbie, I made the mistake, twice, of accidentally typing in:


[root@server ~]# rm -rf /

While what I actually wanted to do was:


[root@server ~]# rm -rf ./

The consequences of such a mistake are severe since you literally deleted the entire filesystem. To prevent this from happening there is a neat little trick:


[root@server ~]# touch — /-i

When you (accidentally) try to delete the root filesystem / you will be asked by the rm command to confirm your action. This way there is a safety that prevents you from deleting the root filesystem without any questions asked.