Friday, December 02, 2011

Samba Server Configuration


Introduction:-
Samba is a software suite that provides file and print sharing services to SMB/CIFS clients. Samba is freely available and it supports Linux/Unix and Windows clients. Samba allows other computer platforms, such as Mac OS, Unix, Linux, IBM System 390 with Windows computers on the same network. Samba includes sharing files and sharing devices such as printer connected to other computers within the local network.

Requirement:-
  • Package = samba
  • Service = smb
  • Port No. = 445
  • Configuration File = /etc/samba/smb.conf
Per quest:-
  • Configure IP = 192.168.1.1
  • Hostname = server.rootuser.in
  • Firewall should be off on server.
1] Install required packages
[root@server ~]# yum install samba* -y

2] Create one new user
[root@server ~]# useradd anup
[root@server~]# passwd anup

3] Create new directory that will host Samba share and grant it full permission.
[root@server ~]# mkdir /mydata
[root@server ~]# chmod 777 mydata

4] Create some files under mydata directory
[root@server ~]# cd /mydata
[root@servermydata]# touch a1 n2 u3 p4
[root@server mydata]# cd

5] Now add anup user to Samba user
[root@server ~]# smbpasswd -a anup
New SMB password:
Retype new SMB password:

6] Use following command to confirm user was added to the samba database
[root@server ~]# pdbedit -w -L

7] Edit main configuration file
[root@server ~]# vim /etc/samba/smb.conf
#By default name of workgroup is MYGROUP you can change to desire name.
workgroup = rootuser
#Remove hash from follwing line and edit as follows
hosts allow 192.168.1.0/24
#Go to end of the file and type as follows:
[mydata]
comment = mysamba
path = /mydata #samba share directory name
public = no #Can not be used by pulic users
browseable = yes
valid users = anup #Only user anup can use samba share
:wq

8] Set Selinux security related options
[root@server ~]# chcon -t samba_shared_t /mydata

9] Use following command to check smb.conf file parameter
[root@server ~]# testparm

10] Start the smb service and make it permanent
[root@server~]# service smb start
[root@server ~]# chkconfig smb on

Client Side Configuration:-
1] Check communication with Samba server
[anup@server ~]$ ping 192.168.1.1

2] Create one directory to store downloaded files.
[anup@server~]$ mkdir /client

3] Now try to connect to Samba server
[anup@server ~]$ smbclient //192.168.1.1/mydata -U anup
Password:
smb:\> ls
smb:\> get a1
smb:\> exit
OR
4] You can also mount samba share directory
[anup@server ~]# smbmount 192.168.1.1:/mydata /client -o username=anup

Windows client side configuration:-
1] Check communication with Samba server
cmd\> ping 192.168.1.1

2] Change computer name to windowsclient and change workgroup to rootuser
Right click on My Computer --> Select Properties --> Click the Computer Name Tab --> Select Change button --> Type the computer name in given filed and type the workgroup name in workgroup filed.

3] After reboot open Go to Start --> Select Search option --> then search Samba server with it's ip

No comments: