Samba Server Configuration in Ubuntu 14.04 LTS

Want to support HowtoForge? Become a subscriber!
 
Submitted by srijan (Contact Author) (Forums) on Wed, 2014-05-28 16:37. :: Linux | Ubuntu | Samba

Samba Server Configuration in Ubuntu 14.04 LTS

Version 1.1
Author: Srijan Kishore
Last edited 30/June/2014

This guide explains how to configure samba server in Ubuntu 14.04 with anonymous & secured samba servers. Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients. Samba is freely available, unlike other SMB/CIFS implementations, and allows for interoperability between Linux/Unix servers and Windows-based clients.

I do not issue any guarantee that this will work for you!

1 Preliminary Note

I have fresh installed ubuntu14.04 server, on which I am going to install the samba server. Off-course you need to have one windows machine to check the  samba server that must be reachable with the ubuntu server. My ubuntu server have hostname server1.example.com & IP as 192.168.0.100

You can have your ubuntu server installed from the starting eleven chapters of this tutorial.

Note:

  • The Windows machine must be on same workgroup. To check the value in windows machine run the command at cmd prompt

net config workstation

It will be like this

Click to enlarge


Your windows machine must be at same Workstation domain as in ubuntu server, i.e. WORKGROUP in my case.
  • To make the windows machine reachable in windows proceed like this. In the run terminal & add  the entry of your server IP address

notepad C:\Windows\System32\drivers\etc\hosts

In my case it was like this, just save the values.

[...]
192.168.0.100 server1.example.com ubuntu


2 Anonymous samba sharing

First I will explain the methodology to install the samba with the anonymous sharing. To install samba run,

apt-get install samba samba-common python-glade2 system-config-samba

It will install samba with version 4.1.6-Ubuntu.

Now to configure samba edit the file /etc/samba/smb.cnf before making changes I will make the backup of original file as  /etc/samba/smb.cnf.bak

mv /etc/samba/smb.cnf /etc/samba/smb.cnf.bak

Further give the entries like this

vi /etc/samba/smb.cnf

[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ============================== 
[Anonymous]
path = /samba/anonymous
browsable =yes
writable = yes
guest ok = yes
read only = no

mkdir -p /samba/anonymous

service smbd restart

Now you can access the ubuntu sharing in windows as follows:

Click to enlarge


From windows machine just browse the folder& try to create a text file, but you will get an error of permission denied.

Click to enlarge


Click to enlarge


Check the permission for the shared folder.

root@server1:~# ls -l /samba/
total 4
drwxr-xr-x 2 root root 4096 May 27 18:17 anonymous
root@server1:~#

To allow anonymous user give the permissions as follows;

root@server1:~# cd /samba
root@server1:/samba# chmod -R 0755 anonymous/
root@server1:# chown -R nobody:nogroup anonymous/
root@server1:/samba# ls -l
total 4
drwx-xr-x 2 nobody nogroup root 4096 May 27 18:17 anonymous
root@server1:/samba#

Now anonymous user can browse & create the folder contents.

Click to enlarge

You can cross check the content at server also.

root@server1:/samba# ls -l anonymous/
total 0
-rwxr--r-- 1 nobody nogroup 0 May 27 18:30 test_samba.txt
root@server1:/samba#


3. Secured samba server

For this I will create a group smbgrp & user srijan to access the samba server with proper authentication

addgroup smbgrp

adduser srijan -G smbgrp

smbpasswd -a srijan

root@server1:~# smbpasswd -a srijan
New SMB password:
Retype new SMB password:
Added user srijan.
root@server1:~#

Now create the folder viz secured in the /samba folder & give permissions like this

mkdir -p /samba/secured
cd /samba
chmod -R 0770 secured/

Again edit the configuration file as :

vi /etc/samba/smb.conf

[secured]
 path = /samba/secured
 valid users = @smbgrp
 guest ok = no
 writable = yes
 browsable = yes

service smbd restart 


Further to cross-check the settings check as follows:

root@server1:~# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[Anonymous]"
Processing section "[secured]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

Now at windows machine check the folder now with the proper credentials

Click to enlarge


Click to enlarge


You will again face the issue of permissions to give write permission to the user srijan do:

Click to enlarge

cd /samba
chown -R srijan:smbgrp secured/


Now samba user srijan  have permissions to write in the folder. Cheers you have done with samba server in Ubuntu14.04.

Click to enlarge


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Sankari Prosad (not registered) on Sat, 2014-06-07 13:03.

why are you giving 777 permission to anonymous folder.As far as I know giving execute permission(where you don't need) on a folder is not a good security practice.

 Apart from that..nice tutorial.thanks.