samba unix man

13
Samba Server Installation and Configuration in CentOS 6.3 / RHEL 6.3 Samba is used to allow users to share and use files, folders and printers between Linux and Windows systems. In this how-to tutorial let us see how to install and configure samba server. Scenario In this tutorial, i use two systems as described below Samba server: Operating system : CentOS 6.3 Hostname : sambaserver.unixmen.com IP Address : 192.168.1.50/24 Samba client: Operating system : Windows 7 Professional Hostname : client IP Address : 192.168.1.51/24 Install Samba package Check and remove any previously installed samba package [root@sambaserver ~]# rpm -qa | grep samba [root@sambaserver ~]# yum list installed | grep samba If it installed, remove it using the below command [root@sambaserver ~]# yum remove samba* Now install samba [root@sambaserver ~]# yum install samba* -y

Upload: rajeshshukla8220

Post on 30-Dec-2015

6 views

Category:

Documents


0 download

DESCRIPTION

Samba Unix Man

TRANSCRIPT

Page 1: Samba Unix Man

Samba Server Installation and Configuration in CentOS 6.3 / RHEL 6.3

Samba is used to allow users to share and use files, folders and printers between Linux and Windows systems. In this how-to tutorial let us see how to install and configure samba server.

ScenarioIn this tutorial, i use two systems as described below

Samba server:Operating system : CentOS 6.3Hostname : sambaserver.unixmen.comIP Address : 192.168.1.50/24

Samba client:Operating system : Windows 7 ProfessionalHostname : clientIP Address : 192.168.1.51/24

Install Samba packageCheck and remove any previously installed samba package[root@sambaserver ~]# rpm -qa | grep samba[root@sambaserver ~]# yum list installed | grep sambaIf it installed, remove it using the below command[root@sambaserver ~]# yum remove samba*Now install samba[root@sambaserver ~]# yum install samba* -y

Configure a fully accessed anonymous shareCreate a directory called ‘/samba/share1′ and set full permission[root@sambaserver ~]# mkdir -p /samba/share1[root@sambaserver ~]# chmod -R 0777 /samba/share1/Edit and add the following lines in samba config file as shown below[root@sambaserver ~]# vi /etc/samba/smb.conf

Page 2: Samba Unix Man

## Line no 58 - Add the following lines below line 58 ##unix charset = UTF-8dos charset = CP932## Line no 75 - Change the to windows default workgroup ##workgroup = WORKGROUP## Line no 81 - Uncomment and set the IP Range ##hosts allow = 127. 192.168.1.## Line 102 - set no authentication ##security = share## Add the following lines at the bottom ##[myshare]path = /samba/share1writable = yesbrowsable = yesguest ok = yesguest only = yescreate mode = 0777directory mode = 0777Start samba server[root@sambaserver ~]# vi /etc/samba/smb.conf[root@sambaserver ~]# /etc/init.d/smb startStarting SMB services: [ OK ][root@sambaserver ~]# /etc/init.d/nmb startStarting NMB services: [ OK ][root@sambaserver ~]# chkconfig smb on[root@sambaserver ~]# chkconfig nmb onTest the Samba serverWe can test the Samba server configuration using the command ‘testparm’.[root@sambaserver ~]# testparmLoad smb config files from /etc/samba/smb.confrlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)Processing section "[homes]"Processing section "[printers]"Processing section "[myshare]"Loaded services file OK.Server role: ROLE_STANDALONEPress enter to see a dump of your service definitions

[global]dos charset = CP932server string = Samba Server Version %vsecurity = SHARElog file = /var/log/samba/log.%mmax log size = 50

Page 3: Samba Unix Man

hosts allow = 127., 192.168.1.cups options = raw

[homes]comment = Home Directoriesread only = Nobrowseable = No

[printers]comment = All Printerspath = /var/spool/sambaprintable = Yesbrowseable = No

[myshare]path = /samba/share1read only = Nocreate mask = 0777directory mask = 0777guest only = Yesguest ok = YesAllow Samba server through firewall[root@sambaserver ~]# vi /etc/sysconfig/iptables# Firewall configuration written by system-config-firewall# Manual customization of this file is not recommended.*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 137 -j ACCEPT-A INPUT -s 192.168.1.0/24 -m state --state NEW -p udp --dport 138 -j ACCEPT-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 139 -j ACCEPT-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 445 -j ACCEPT-A INPUT -s 192.168.1.0/24 -m state --state NEW -p tcp --dport 901 -j ACCEPT-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited-A FORWARD -j REJECT --reject-with icmp-host-prohibitedCOMMITRestart iptables to save the changes[root@sambaserver ~]# service iptables restartiptables: Flushing firewall rules: [ OK ]

Page 4: Samba Unix Man

iptables: Setting chains to policy ACCEPT: filter [ OK ]iptables: Unloading modules: [ OK ]iptables: Applying firewall rules: [ OK ]Disable SELINUX[root@sambaserver ~]# vi /etc/sysconfig/selinux# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPE=targetedRestart the server and goto windows client systemClick Start -> Run. Enter the samba Server IP as shown below.

Page 5: Samba Unix Man

Now create some folders and files

Page 6: Samba Unix Man

Check whether the newly created files or folders present in the samba server[root@sambaserver ~]# ls -l /samba/share1/total 4drwxrwxrwx 2 nobody nobody 4096 Mar 8 22:59 unixmen

Configure a authenticated share using samba serverCreate a user called “sk” and a group called “smbgroup”. Add the user “sk” to the group “smbgroup”[root@sambaserver ~]# useradd sk[root@sambaserver ~]# groupadd smbgroup[root@sambaserver ~]# usermod -a -G smbgroup sk[root@sambaserver ~]# smbpasswd -a skNew SMB password:Retype new SMB password:Added user sk.Create a new share called “/samba/share2″ and set the permissions to that share.

Page 7: Samba Unix Man

[root@sambaserver ~]# mkdir /samba/share2[root@sambaserver ~]# chmod -R 0755 /samba/share2/[root@sambaserver ~]# chown -R sk:smbgroup /samba/share2/Add the below lines at the bottom of samba config file.[root@sambaserver ~]# vi /etc/samba/smb.conf[secure]path = /samba/share2writable = yesbrowsable = yesguest ok = novalid users = @smbgroupTest the configuration for any errors[root@sambaserver ~]# testparmLoad smb config files from /etc/samba/smb.confrlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)Processing section "[homes]"Processing section "[printers]"Processing section "[myshare]"Processing section "[secure]"Loaded services file OK.Server role: ROLE_STANDALONEPress enter to see a dump of your service definitions

[global]dos charset = CP932server string = Samba Server Version %vsecurity = SHARElog file = /var/log/samba/log.%mmax log size = 50hosts allow = 127., 192.168.1.cups options = raw

[homes]comment = Home Directoriesread only = Nobrowseable = No

[printers]comment = All Printerspath = /var/spool/sambaprintable = Yesbrowseable = No

[myshare]

Page 8: Samba Unix Man

path = /samba/share1read only = Nocreate mask = 0777directory mask = 0777guest only = Yesguest ok = Yes

[secure]path = /samba/share2valid users = @smbgroupread only = NoRestart samba server[root@sambaserver ~]# /etc/init.d/smb restartShutting down SMB services: [ OK ]Starting SMB services: [ OK ][root@sambaserver ~]# /etc/init.d/nmb restartShutting down NMB services: [ OK ]Starting NMB services: [ OK ]Now goto windows client and try to access the secured share.

Page 9: Samba Unix Man

Configure samba server in GUI modeIf you struggle with command line configuration, you can configure samba server in GUI mode too using “samba-swat” package. I prefer and suggest you command line mode only.Install the “samba-swat” package if it is not installed.[root@sambaserver ~]# yum install xinetd samba-swat -y

Configure SWATOpen the “samba-swat” config file and edit as shown below[root@sambaserver ~]# vi /etc/xinetd.d/swat# default: off# description: SWAT is the Samba Web Admin Tool. Use swat \# to configure your Samba server. To use SWAT, \# connect to port 901 with your favorite web browser.service swat{port = 901socket_type = streamwait = noonly_from = 127.0.0.1 192.168.1.0/24user = rootserver = /usr/sbin/swatlog_on_failure += USERIDdisable = no}Restart samba and xinetd services[root@sambaserver ~]# /etc/init.d/xinetd restartStopping xinetd: [ OK ]Starting xinetd: [ OK ][root@sambaserver ~]# /etc/init.d/smb restartShutting down SMB services: [ OK ]Starting SMB services: [ OK ][root@sambaserver ~]# /etc/init.d/nmb restartShutting down NMB services: [ OK ]Starting NMB services: [ OK ]Open the web browser from any client syatems. In the address bar type “http://server-ip-address:901″ and press enter. Now the console screen will open. You can start configure samba server here.

Page 10: Samba Unix Man
Page 11: Samba Unix Man

Thats it. Enjoy.- See more at: http://www.unixmen.com/samba-server-installation-and-configuration-in-centos-6-3-rhel-6-3/#sthash.ktcFaZGP.dpuf