How do I share a folder with another Linux machine on the same home network?

What does Windows have to do with this? I'm not trying to share with a Windows machine...

You're right, this can be confusing. So let me try to clarify the terms first of all:

The way Windows shares files and printers is called SMB. The people from the SAMBA project have implemented all of Microsoft's protocols and specifications for Linux. Ubuntu therefore supports the same sort of file sharing as Windows, which is called Samba.

  • You can use SAMBA to share files between Linux machines. In fact, you might prefer it in case you have, for example, have a friend over with their Windows computer.

  • Alternatively, you can use The Linux Way of sharing files, which is NFS (Network File System) - This answer to a previous question explains how to do it. (but it's rather technical)

So, when the Sharing Options dialogue asks you to install the packages, you're not actually installing any Microsoft software or anything like that. Go ahead and do it, it's perfectly safe.

Addendum:

You can try to just enable sharing before you follow Salih Emin's instructions; if it doesn't work, you will get a simple warning, you can then do the steps Salih describes if needed. I have tried it on a freshly installed and up-to-date system, and I indeed needed to do this.


At present, there is a small bug in Lucid which is listed in Launchpad: bug #536766. This bug doesn’t prompt the user to install the necessary packages needed to complete the file sharing set-up. Until that is addressed, here is a quick workaround.

You need to install libapache2-mod-dnssd and restart. Click this link to install it, or find libapache2-mod-dnssd in the Software Centre.

Once you have it installed, head over to System → Preferences → Personal file Sharing, and check the 'Share public files on network' box.

alt text

Once that is all done, you should then be able to view all other computers on your network that have allowed public file sharing within the Public folder. Just click on Places → Network, and there you should see all available computers and their shared Public folders.

Double-clicking on the server icon will mount the relevant public folder on your desktop.

Via link text


I find SSHFS to be native, stable and extremely fast. I have two xubuntu machines (18.04) sharing /home folders and an Intel NUC as 'dropbox' USB stick. All over sshfs.

UPDATE 2020-07-12: I found SSHFS for Windows. A clean beautiful GUI, zero config and works with the SSH keys from linux-machines.

  • Howto: https://github.com/billziss-gh/sshfs-win
  • GUI https://github.com/evsar3/sshfs-win-manager

Here's how to set this up sshfs and automatically reconnecting after a reboot using fstab without having to provide a password. A big thank you to serverfault user kubanczyk for how to reconnect after a remote suspend/resume.

I'll use "Local machine - surfbox" for computer you're connecting from, and "Remote machine - devbox" for the computer you're connecting to.

Check your userID och groupID, they should both be 1000.

GroupID: id -g localuser UserID: id -u localuser

1. Get IP-adresses of your Local & Remote Machines.

hostname -I

I'll use 192.168.1.150 for Local Machine ('surfbox') and 192.168.1.151 for Remote Machine ('devbox')

2. Install packages on Local and Remote Machines

sudo apt install sshfs fuse ssh

3. Create a group fuse and add localuser to it

Create group: sudo groupadd fuse

Add localuser to the group: sudo usermod -a -G fuse $user

4. Enable "allow_other" in fuse config

We will need this option when mounting in fstab

Edit /etc/fuse.conf with your command line editor. Remove the hashtag before user_allow_other and save.

5. Generate SSH keys on Local Machine

Do not provide a password when prompted. Just press Enter to leave blank.

ssh-keygen -t rsa -C [email protected]

Keys are stored in Local machine home directory /.ssh folder

6. Transfer your Local machine public SSH key to the Remote machine

ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]

You will be prompted for password for Remote user on Remote machine. Local machine public key is now added to the file ~/.ssh/authorized_keys on Remote machine.

7. Create a directory on Local machine /mnt folder where you will mount the Remote machine /home folder.

Choose any name which makes sense for your Remote machine.

sudo mkdir /mnt/devboxhome

8. Mount the Remote machine /home directory from terminal

Syntax for sshfs is

sshfs [user@]host:[directory] mountpoint [options]

we use

sudo sshfs [remoteuser]@192.168.1.151:/home/[remoteuser] /mnt/devboxhome -o allow_other,default_permissions -o identityfile=/home/[localuser]/.ssh/id_rsa

example: assuming "steve" is the username on both Local and Remote machines

sudo sshfs [email protected]:/home/steve /mnt/devboxhome -o allow_other,default_permissions -o identityfile=/home/steve/.ssh/id_rsa

Since you have transferred the public RSA key to Remote machine you should not be prompted for remoteuser password.

You will get a warning that the machine is not trusted and prompted if it should be added. Add the Remote machine as trusted.

9. Verify: Browse Remote Machine /home directory

In terminal on Local machine you can now list Remote machine /home directory under /mnt/devboxhome

cd /mnt/devboxhome ls

or use Nautilus to browse the directory. Great.

10. Enable reconnect after reboot

We will add an entry in /etc/fstab to make this happen. You will need your Local machine userid och groupid - see intro if you missed this. Edit /etc/fstab with your command line editor and add these two lines at the end of /etc/fstab

# Mount devbox at boot [email protected]:/home/[remoteuser]/ /mnt/devboxhome fuse.sshfs default_permissions,user,delay_connect,reconnect,ServerAliveInterval=15,ServerAliveCountmax=3,allow_other,identityfile=/home/[localuser]/.ssh/id_rsa,idmap=user,uid=1000,gid=1000 0 0

  • delay_connect makes the kernel wait until the network is up until it tries to mount the directory on Remote machine.
  • Since we are running as root during boot we have to specify the keyfile which is stored in localuser home directory.
  • allow_other - users other than the one doing the actual mounting can access the mounted filesystem.
  • idmap=user - only translate UID of connecting user
  • reconnect, ServerAliveInterval, ServerAliveCountMax - ssh sends keep-alive pings. If ServerAliveCountMax consecutive pings fail, reconnect.

A user logging in as steve on Local and Remote machines would have:

[email protected]:/home/steve/ /mnt/devboxhome fuse.sshfs default_permissions,user,delay_connect,reconnect,ServerAliveInterval=15,ServerAliveCountmax=3,allow_other,identityfile=/home/steve/.ssh/id_rsa,idmap=user,uid=1000,gid=1000 0 0

IMPORTANT: a slash after remote directory: [email protected]:/home/steve/

save /etc/fstab and ....

11. Reboot

You should now be able to access Remote machine /home directory in the Local machine /mnt/devboxhome In Nautilus you can drag this folder to the Places bar

12. Repeat

Go through the same steps again on Remote machine to make the /home directory of Local machine shared.