SETTING UP SAMBA SHARING SERVER ON ARCH LINUX
Original https://lampjs.wordpress.com/2018/08/10/setting-up-samba-sharing-server-on-arch-linux/
Samba facilitates file and printer sharing among Linux and Windows systems. To share contents of linux server there should be a sharing server running, mostly Samba is used as sharing server on linux machines.
Follow the steps below to install Samba on PC where you need to share files.
Install Samba
1 | # pacman -S samba |
Create configuration file for Samba, it is required but not automatically created when installing samba so have to manually create it.
1 | # vi /etc/samba/smb.conf |
Copy the content from Sample Configuration from Samba Git Repo and paste in above file.
Lets modify configuration to get it working.
For better security provide min protocol and max protocol versions, add protocols in global section.
123 | [global] server min protocol = NT1 server max protocol = SMB3 |
Set workgroup, you can set your own workgroup name, I set it DEVTEAM
1 | workgroup = DEVTEAM |
Set server description, this is visible when querying server from samba client, my PC host name is TECNOTCH
1 | server string = Samba Server on TECNOTCH |
Change the default log file path as it is not writable, set it to
1 | log file = /var/log/samba/ %m.log |
Restrict home directories being shared, add ; before every line in [homes] section
1234 | ;[homes] ;comment = Home Directories ;browseable = no ;writable = yes |
At the end of file uncomment [myshare] section and change as required, this is the share name that appears on client, I changed [myshare] to [shared]
12345678 | [shared] comment = TECNOTCH Shared Files path = /mnt/data/shared valid users = tofeeq anyotheruser1 anyotheruser2 public = no writable = yes printable = no create mask = 0765 |
We have done configurations, Great. Now save the file using :wq and add users to samba server
Samba server requires user to access user shared directories if those are not public, Samba shares the linux system user name but maintains its own password.
So we don’t have to actually add the user but we are going to add a password in Samba list.
1 | # smbpasswd -a tofeeq |
Type your password and enter
You can change password later by using
1 | # smbpasswd tofeeq |
Create the shareable directory
Remember we have created a [shared] section in smb.conf file? There we have configured path for shareable directory
123 | [shared] comment = TECNOTCH Shared Files path = /mnt/data/shared |
Create a directory shared in /mnt/data location
1 | # mkdir -p /mnt/data/shared |
Change ownership of file to the user that was added in samba, in my case it was tofeeq, assign ownership to tofeeq for /mnt/data/shared directory
1 | #chown -R tofeeq:users /mnt/data/shared |
Cool, all setup now start the samba server
12 | # systemctl start smb.service # systemctl start nmb.service |
You can set them autostart on system boot
12 | # systemctl enable smb.service # systemctl enable nmb.service |
Congratulations, your samba server is up and running, now you can access your linux server’s shared folders from any other pc including windows. To access them on linux you need to have samba client and mount network directory.