Friday, January 31, 2014

How to configure Samba Server on Red Hat Enterprise Linux 5


Samba server:

The Samba server is the preferred tool to install a LAN (Local Area Network) working with the SMB protocol (Server Message Block). It is therefore possible to mix efficiently in the same network Linux and Windows PC with knowledge of the server software.
Its usefulness: SAMBA is a system for sharing files and printers between Linux and Windows in a transparent and stable.
 Red Hat Linux can become a Samba server by installing the Samba rpm package either through the command line or the GNORPM tool. The next step is to edit the /etc/smb.conf file after copying it to a file with the .bak extension. It takes a bit of trial and error to come up with a good configuration that works. The testparms command can be used to check for errors in the /etc/smb.conf file. Make sure that the server is restarted after every configuration change using the /etc/rc.d/init.d/smb restart command. To avoid any permission problems, make sure that an smb password file is created using the smbpasswd command. Linuxconf and webmin can also be used to configure the Samba server using a nicely formatted GUI or web-based interface. SWAT is a web-based Samba configuration tool which can also be accessed inside webmin.

Installing & Configuring a Samba Server:

The default configuration file (/etc/samba/smb.conf) allows users to view their Red Hat Linux home directories as a Samba share. It also shares any printers configured for the Red Hat Linux system as Samba shared printers. In other words, you can attach a printer to your Red Hat Linux system and print to it from the Windows machines on your network.
Command Line Configuration:

Open terminal and type these commends to install samba server packages from yum server.
[root@localhost ~]# yum install samba*
[root@localhost ~]# service smb restart
Shutting down SMB services:                                 [  OK  ]
Shutting down NMB services:                                [  OK  ]
Starting SMB services:                                           [  OK  ]
Starting NMB services:                                          [  OK  ]

[root@localhost ~]# chkconfig smb on

 Samba uses /etc/samba/smb.conf as its configuration file. If you change this configuration file, the changes do not take effect until you restart the Samba daemon with the command service smb restart. To specify the Windows workgroup and a brief description of the Samba server, edit the following lines in your smb.conf file:

[root@localhost ~]# vi /etc/samba/samba.conf   -->(vi cmd opens the file)

(edit the following lines in the file by pressing key 'i') 

   workgroup = MYGROUP
   server string = Samba Server Version %v

;       netbios name = MYSERVER

;       interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
        hosts allow = 127. 192.168.1. 192.168.188.     

 (edit here the n/w ID you desired to share samba server)

(in the end of the file u will find these lines edit them or copy them and past them down to these and then edit them as shown below)


# A publicly accessible directory, but read only, except for people in
# the "staff" group
;       [public]
;       comment = Public Stuff
;       path = /home/samba
;       public = yes
;       writable = yes
;       printable = no
;       write list = +staff

(edit in this way as per your requirements)

        [shared]
        comment = shared
        path = /shared
        public = yes
        writable = yes
        printable = yes
        browseable=yes
        write list = +staff
:wq!

[root@localhost ~]# service smb restart
Shutting down SMB services:                                [  OK  ]
Shutting down NMB services:                                [  OK  ]
Starting SMB services:                                     [  OK  ]
Starting NMB services:                                     [  OK  ]

[root@localhost ~]# chkconfig smb on

[root@localhost ~]# testparm

(cmd shows details of samba server shared directory)

Load smb config files from /etc/samba/smb.conf
Processing section "[homes]"
Processing section "[printers]"
Processing section "[shared]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
        workgroup = MYGROUP
        server string = Samba Server Version %v
        security = SERVER
        passdb backend = tdbsam
        idmap uid = 16777216-33554431
        idmap gid = 16777216-33554431
        hosts allow = 127., 192.168.1., 192.168.188.
        cups options = raw

[homes]
        comment = Home Directories
        read only = No
        browseable = No

[printers]
        comment = All Printers
        path = /var/spool/samba
        printable = Yes
        browseable = No

[shared]
        comment = shared
        path = /shared
        write list = +staff
        read only = No
        guest ok = Yes
        printable = Yes


[root@localhost ~]# useradd ravi
[root@localhost ~]# passwd ravi
Changing password for user ravi.
New UNIX password:                    (type here the desired password)
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:        (again type here the desired password)
passwd: all authentication tokens updated successfully.
[root@localhost ~]# smbpasswd -a ravi        (samba login ID)
New SMB password:                                         (type samba ID’s password)
Retype new SMB password:
Added user munna.
[root@localhost ~]# smbclient //192.168.1.15/shared -U ravi
Password:
[root@localhost ~]# chcon -R -t samba_shared_t /shared
[root@localhost ~]# setsebool -P samba_enable_home_dirs=1 -->(cmd to solve selinux error

Samba server configuration has finish.
 

No comments:

Post a Comment