I'm trying to share a folder on one Ubuntu machine with another Ubuntu machine on the same home network. When I right click on the folder and choose Sharing Options, it tells me I need to install Windows network sharing services in order to share folders. What does Windows have to do with this? I'm not trying to share with a Windows machine...
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.
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.
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.
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.
id -g localuser
id -u localuser
1. Get IP-adresses of your Local & Remote Machines.
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
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
/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@example.com
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 firstname.lastname@example.org
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]
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@example.com:/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 firstname.lastname@example.org:/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
ServerAliveCountMaxconsecutive pings fail, reconnect.
A user logging in as steve on Local and Remote machines would have:
email@example.com:/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: firstname.lastname@example.org:/home/steve/
save /etc/fstab and ....
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
Go through the same steps again on Remote machine to make the /home directory of Local machine shared.
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.
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
You Can simply run an simpleHTTP server in the linux machine and access the same on the other machine.
- first start the terminal from the folder to be shared.
- run in terminal -
python -m SimpleHTTPServer
- check your ip using
- enter in the browser of the other machine the ip address:8000 (e.g.: if your ip is 127.3.4.123 then in browser you type 127.3.4.123:8000)
You get the required files in the folder to download.
If you want seamless integration in Ubuntu, and you aren't interested in Windows compatibility, SSH is your huckleberry.
You may need to install the SSH server with:
sudo apt-get install openssh-server
From the file-manager app on your client, you can get to your server with:
To access files from a terminal or programmatically, use
sshfs to create a mount-point in the client's file system.
zx81roadkill is right, use "sshfs". Samba is crap, NFS is garbage. Sshfs is entirely usable from my computer here in California, to a computer in Argentina. It's entirely secure, it's just as fast as anything else (I have a gibabit line).
Sshfs is relatively a newcomer compared to Samba and NFS, but it's far superior to either. Here's an example of running it (assuming you have all the packages installed)
# mount "username"'s home directory on "machine" mkdir -p /tmp/my_mount ; sshfs username@machine: /tmp/my_mount # mount the root directory on "machine" (note: if "username" on "machine" # can't write to the file, neither will you. You have "username"'s privs mkdir -p /tmp/my_mount ; sshfs username@machine:/ /tmp/my_mount # mount the directory "Videos" on "username"'s account on "machine" mkdir -p /tmp/my_mount ; sshfs username@machine:Videos /tmp/my_mount
Once you enter the password, /tmp/my_mount will contain all the files of "username" on "machine". Don't bother to futz around with Samba or NFS. They're just a pointless pain in the butt to either configure, or setup.
fusermount -u /tmp/my_mount
and if that fails (for whatever reason):
umount -f /tmp/my_mount
All data sent through the mount point is encrypted. Why this isn't the standard, entirely accepted way, of doing a mount to a remote machine is a mystery to me. It's vastly superior to any other method in terms of simplicity.
If you need raw speed, perhaps that bloated piece of junk Samba will do it, or NFS. I don't know, 100 MB/s+ is good enough for me.