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...
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.
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.
GroupID:
id -g localuser
UserID: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
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 beforeuser_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
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.
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.
Steps :
python -m SimpleHTTPServer
ifconfig
.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.
See How can I share files between two Linux machines over LAN?
You may need to install the SSH server with:
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.I believe that's what SAMBA packages are listed under, or it's at lest part of their description. As an alternative, you can try Preferences->File Sharing which I believe uses a different mechanism. Samba is a handy thing to have installed though.
You can install "qweborf". It will share the directory over HTTP and the other hosts will be able to access with a browser.
It can also enable webdav and enable the directory to be mounted as read/write a filesystem (tested with davfs2,KDE,Gnome2,OsX).
My way of sharing files:
Go to the folder you like to share, open terminal and run this command:
You'll be able to access that folder in all machines in the same network on the IP address mentioned by the output of that command.
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)
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.
To unmount:
and if that fails (for whatever reason):
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.