Whenever two (or more) computers are connected to each other, there are certain things they want to do: Usually files need to be shared among users on the systems and printers should be available for printing from all workstations (and even from the playstations
). The way to achieve this is called protocol. In order to share files and printers, the OSes on all machines involved have to speak the same language, follow the same protocol.
If only UN*X machines are involved, data-transfer via the Secure SHell protocoll has become the standard. In this lesson we will assume there is a linux-only network (read: Only Linux-PCs will offer and/or ask for files). Windows-PCs can be in the network, but if they want to take part in the sharing, we will have to use the SMB-Protocol. SMB is explained in the Samba-Lesson.
Since most Linux-Servers have remote acces via SSH enabled, there is nothing to be done. If your server is one of those without preinstalled SSH (like many new distros), you will need to install it using the distributions package management tool (Debian/Ubuntu: “sudo apt-get install ssh”)
If you can access the server like it is described in this tutorial, you are all set to go.
On the client-computer, you need to install the SSHFS-package and dependencies. (Debian/Ubuntu: “sudo apt-get install sshfs”). You will also need to make sure that the device /dev/fuse is owned by a group in which your regular user is member in.
stw@fourgb:~$ ls -l /dev/fuse crw-rw---- 1 root fuse 10, 229 2007-10-17 08:56 /dev/fuse
On my system, I had to change the group of the file (“sudo chown :fuse /dev/fuse”, add myself to the fuse-group “sudo adduser stw fuse” and finally log out and in to make that change visible to the shell. (chgrp would have done, too)
Like always, if we want to mount a filesystem, we need to create a directory as mountpoint (“mkdir /NET/stefan.waidele.info”). Then we issue the sshfs-command, which will mount the remote filesystem for us:
stw@fourgb:~$ mkdir /NET/stefan.waidele.info stw@fourgb:~$ sshfs stw@stefan.waidele.info:/home/www/stefan.waidele.info /NET/stefan.waidele.info
With these commands, and some more just like them, I can use all the websites I have, just like they were right here in my own PC.
stw@fourgb:/NET$ df -h
[...]
/dev/sda3 134G 20G 108G 16% /SRV
/dev/hda 25M 25M 0 100% /media/cdrom0
sshfs#stw@linuxbasics.org:/home/www/
7,5T 0 7,5T 0% /NET/linuxbasics.org
sshfs#stw@sl.stots.de:/home/www/solitudR.com
7,5T 0 7,5T 0% /NET/solitudR.com
sshfs#stw@stefan.waidele.info:/home/www/stefan.waidele.info
7,5T 0 7,5T 0% /NET/stefan.waidele.info
sshfs#stw@krone-neuenburg.de:/home/www/krone-neuenburg.com
7,5T 0 7,5T 0% /NET/krone-neuenburg.de
Applications do not know that these files and directories are remote, so I can use anything to work on them. I can manipulate images right on the webserver, I can search or edit the HTML-files with whatever I want, I could even save screenshots right into my webspace!
The price for this functionality and ease is a decrease in speed, since the data has to be send to and from the server. So you have to judge yourself if you actually do all you could do over sshfs. But since there is a trend to storing more and more data “on the web”, SSHFS on a server of your own is a good alternative to “missusing” a freemailer…
To disconnect, a simple “umount /NET/linuxbasics.org” (or whatever the mountpoint was) is enough. No questions, no tears, no hard feelings :)
Copyright (c) by the authors.
Prior to editing, authors agreed to license their contributions by the terms of the GPL.
See our licensing page for details.
Linux® is a registered trademark of Linus Torvalds.