To install a fileserver and having shared folders is common practice both in a office or at home. One may prefer the Windows way for setting these shares up, but I’m using Samba for quite a few years now and talking of shares… here it is my configuration! I applied a “hack” on the Windows eth card too, you will read why
To develop this configuration file I read the manual of Samba and extracted the most useful options.
First of all, you’d need to install Samba.
apt install samba smbclient -y
Then, backup your current smb.conf.
cp /etc/samba/smb.conf /etc/samba/smb.conf.original
cd /etc/samba >smb.conf vi smb.conf
And paste the first part of the configuration file:
[global] server string = %h server (Samba, Ubuntu) map to guest = Bad User obey pam restrictions = Yes pam password change = Yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . unix password sync = Yes syslog = 0 log file = /var/log/samba/log.%m max log size = 1000 deadtime = 45 socket options = TCP_NODELAY IPTOS_THROUGHPUT dns proxy = No panic action = /usr/share/samba/panic-action %d idmap config * : range = idmap config * : backend = tdb map acl inherit = Yes csc policy = documents # interfaces = 10.8.0.0/24 tun0 # do you want to serve your Samba over a dedicated network? # hosts allow = 10.8.0.0/24 # these rows are what I'd use in the OpenVPN
Write this on the file and close it [ :wq ].
At this point, how many shared folders are we going to create? Which users/groups should access?
In this example, Juri wants a personal folder, just for him.
We’re going to create this user on the Ubuntu server:
useradd juri passwd juri
After the creation of Juri, Samba must be aware of the new user.
smbpasswd -a juri
No need for the password to match.
We need to create his shared folder.
mkdir -p -m 770 /home/samba/juri chown -R juri:juri /home/samba/juri
And allow U.G.O. to execute the root of Samba (enter).
chmod 755 /home/samba
When done, we can reopen smb.conf and create the share definition.
Reach the bottom of the file and type:
[Juri] path = /home/samba/juri valid users = juri force group = juri read only = No directory mask = 0770 force directory mode = 0770 create mask = 0660 force create mode = 0660 write cache size = 2621440 veto oplock files = /*.tmp/
Only the user juri can access this share.
And to create a share for groups?
Useful where more user must have access to it.
On valid users, one could use @group
The @ associated to the valid users allows the member of this group to access the share, the permissions on the file created will be set accordingly.
Note that if the shared folder belongs to a group, it is important to
chown -R root:group /home/samba/groupFolder
And the definition for the group would be the same, but:
[Group] path = /home/samba/groupFolder valid users = @group force group = group
After a Samba restart, Windows should be able to access this share. It is a common issue that one where the shares can be really slow to load on Windows, sometimes loading forever and never open.
About Windows “hack”…
The problem is that Windows 7 (and latest) incorporates some features that can slow down connections with other operating systems. With these changes, Windows can gain speed connections to shared resources on Linux.
1. Disable autotuning
Open the cmd as administrator and type:
netsh interface tcp show global
Check the row that says about autotuning, it should be on “normal”. Deactivate it:
netsh interface tcp set global autotuning=disabled
Should just say “OK.”.
Check it again with the “show” command and see if it is deactivated now. If it is…
2. Disable RDC (remote differential compression)
Go to control panel, programs and feature and “turn windows feature on/off”.
Uncheck “Remote differential compression”.
Reboot Windows and restart Samba. Enjoy your fast shared folder!