Wise people learn when they can; fools learn when they must - Arthur Wellesley

Sunday, 5 August 2018

LINUX- 34 CONFIGURING SAMBA (RHEL-7)-P1


                LINUX- 34 CONFIGURING SAMBA (RHEL-7)-P1

All posts under samba,

CONFIGURING SAMBA (RHEL-7)-P1
CONFIGURING SAMBA (RHEL-7)-P2


What is SAMBA and how to configure it in RHEL7.

Samba is an open-source Linux implementation of the Server Message Block (SMB) and Common Internet File System (CIFS) protocols which uses TCP/IP protocol and It allows us to share files, folders, and printers between Linux server and Windows clients.

In Linux SAMBA provides the following services:

User Authentication and authorization
File and printer sharing
Name resolution
Browsing

Packages Required: samba*
Port Number:
137 tcp & udp
138 tcp & udp
139 tcp & udp
445 tcp & udp
Daemon:
1) smbd: It provides the file and printer sharing services along with authentication.
2) nmbd: The nmbd daemons provides NetBIOS (Network Basic Input/output system) name serving and browsing support. 
   A daemon that looks after the Windows Internet Name-Service (WINS) and assist with browsing. According to samba documentation, it should be the first daemon to start.
3) winbindd: for host and user name resolution / to handle Microsoft Windows Domain membership.
Config File Location: /etc/samba/smb.conf

INSTALLING SAMBA,

[root@rhel7-server ~]# rpm -qa |grep samba
[root@rhel7-server ~]# yum install samba* -y
[root@rhel7-server ~]# rpm -qa |grep samba
samba-4.1.1-31.el7.x86_64
samba-winbind-modules-4.1.1-31.el7.x86_64
samba-libs-4.1.1-31.el7.x86_64
samba-client-4.1.1-31.el7.x86_64
samba-python-4.1.1-31.el7.x86_64
samba-common-4.1.1-31.el7.x86_64
samba-winbind-4.1.1-31.el7.x86_64

[root@rhel7-server ~]# systemctl status smb
smb.service - Samba SMB Daemon
   Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled)
   Active: inactive (dead)

Aug 04 18:02:18 rhel7-server systemd[1]: Stopped Samba SMB Daemon.
[root@rhel7-server ~]# systemctl status nmb
nmb.service - Samba NMB Daemon
   Loaded: loaded (/usr/lib/systemd/system/nmb.service; disabled)
   Active: inactive (dead)

Aug 04 18:02:18 rhel7-server systemd[1]: Stopped Samba NMB Daemon.

Activating Samba services at boot,

[root@rhel7-server ~]# systemctl enable smb
ln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/multi-user.target.wants/smb.service'

[root@rhel7-server ~]# systemctl enable nmb
ln -s '/usr/lib/systemd/system/nmb.service' '/etc/systemd/system/multi-user.target.wants/nmb.service'

Starting Samba services,

[root@rhel7-server ~]# systemctl start smb
[root@rhel7-server ~]# systemctl start nmb

CONFIGURATION:

* Create a dir for sharing
* Add a new user for samba (we can use existing as well)
* Add a new group for samba (we can use existing as well)
* Change ownership of dir and add user to group
* Copy the smb file and configure with above details
* Validate the configuration
* Set the samba password for created user
* Test the configuration


[root@rhel7-server ~]# mkdir /samba-share-test
[root@rhel7-server ~]# chmod 777 /samba-share-test
[root@rhel7-server ~]# groupadd sambagr
[root@rhel7-server ~]# useradd -s /sbin/nologin -G sambagr sambatest
[root@rhel7-server ~]# chgrp sambagr /samba-share-test
[root@rhel7-server ~]# chown sambatest:sambagr /samba-share-test
[root@rhel7-server ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.org
[root@rhel7-server ~]# vi /etc/samba/smb.conf
[sambashare]
comment = Samba-shared-directory
path = /samba-share-test
public = no
valid users = sambatest, @sambagr
writable = yes
browseable = yes
create mask = 0755
guest ok = no
write list = @sambagr
read list = sambatest

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

[root@rhel7-server ~]# smbpasswd -a sambatest
New SMB password:
Retype new SMB password:
Added user sambatest.

**If using existing user for samba then password must be same as in /etc/password.

[root@rhel7-server ~]# systemctl restart smb
[root@rhel7-server ~]# systemctl restart nmb

# smbclient //localhost/samba-share-test -U sambatest%redhat
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
tree connect failed: NT_STATUS_BAD_NETWORK_NAME

If we are getting above error means either we have to check for shared dir permission or need to look in to samba configuration under smb.conf

[root@rhel7-server ~]# ls -ld /samba-share-test
drwxrwxrwx. 2 sambatest sambagr 6 Aug  5 12:51 /samba-share-test

Its already highest permission set on shared dir

[root@rhel7-server ~]# vi /etc/samba/smb.conf
[sambashare]  çç This is Culprit
comment = Samba-shared-directory
path = /samba-share-test
public = no
valid users = sambatest, @sambagr
writable = yes
browseable = yes
create mask = 0755
guest ok = no
write list = @sambagr
read list = sambatest


[samba-share-test]  çç Changed it like this
comment = Samba-shared-directory
path = /samba-share-test
public = no
valid users = sambatest, @sambagr
writable = yes
browseable = yes
create mask = 0755
guest ok = no
write list = @sambagr
read list = sambatest

wq!

[root@rhel7-server ~]# systemctl restart smb
[root@rhel7-server ~]# systemctl restart nmb

Let’s try it again,

# smbclient //localhost/samba-share-test -U sambatest
Enter sambatest's password:
Domain=[MYGROUP] OS=[Unix] Server=[Samba 4.1.1]
smb: \> ls
NT_STATUS_ACCESS_DENIED listing \*
smb: \>

It’s not allowing to access the dir. Let’s check from windows side




I tried with all three active IP’s, and see the result.



What could be the reason…?

No comments:

Post a Comment