Mount a remote directory over a local network using sshfsGuide Overview
The purpose of this guide is to teach you how to mount a remote directory over a local network using sshfs. This is an easy way to share files between Linux computers over a local network particularly when they are owned by the same user, as no root permissions are required, which is the case for the purpose of this guide.
- Two Linux computers and a router.
- Install sshfs (unless it is already installed) on both machines. In Debian-based distros, run this command in a terminal:
apt-cache policy sshfsThat will tell you whether it's already installed on your system and if it's available for installation. If it's not installed, but is available, install it by running this command in a terminal:
sudo apt-get install sshfs
- If either computer uses a firewall, create an exception for ssh. In Debian'based systems that use ufw, you can create an exception by running this command in a terminal:
sudo ufw allow sshIf both computers use a firewall, be sure to do the same on each one.
- Now create a mount point in your user's home directory. (A mount point is a directory for mounting a file system in). While file systems on other devices are ordinarily mounted in /media or /mnt, you can mount them anywhere.
To create a mount point in your user's home directory called "mountp", open a terminal in your user's home directory and run this command:
- You can mount any directory that you are the owner of, without using root permissions, but for the purpose of this guide I'll mount my user's home directory from the remote system.
To mount your user's home directory from the remote system, run this command in a terminal (from your user's home directory, where you created the mountpoint), swapping "yourusername" for your user name, and "remotesystemname" for the name of the remote system. This information is available from the command prompt in a terminal; the text preceding @ is your username, and the text following @ is the name of your system. For example, the command prompt on my remote system reads al@puppy-pc:~$ so my username is al and the name of the system is puppy-pc.
sshfs yourusername@remotesystemname:/home/yourusername mountpSo I would type:
sshfs al@puppy-pc:/home/al mountp
- Enter your password for the remote computer at the prompt.
If you are not asked for your password, please see post #2 for another method.
- Your user's home directory from the remote computer, should now be mounted in mountp.
You can now open mountp in your file manager, and drag and drop files to and from your user's home directory on your remote computer, as if it was a directory on the computer you are using.
- To unmount the remote directory, open a terminal in your user's home directory and run this command:
fusermount -u mountp