Samba
three services
(smb)
provides file sharing and printing services to Windows clients
it is responsible for user authentication, resource locking, and data sharing
through the SMB protocol
TCP ports Smp/139 and cifs/445
nmb
the nmbd server daemon understands and replies to NetBIOS name service
requests such as those produced
by SMB in Windows-based systems
These systems include Windows 95/98/ME, Windows NT, Windows 2000, Windows XP,
and LanManager clients.
It also participates in the browsing protocols that make up the Windows
Network Neighborhood
UDP port 137 ,138
winbind
The winbind service resolves user and group information on a server running
Windows NT 2000 or Windows Server 2003.
This makes Windows user / group information understandable by UNIX platforms.
This is achieved by using Microsoft RPC calls
This allows Windows NT domain users to appear and operate as UNIX users on a
UNIX machine
Winbindd is also used when Samba is an Active Directory member
####on server
1- create directory structure
2- set directory group and permissions
3- set directory ownership
4- set selinux context (samba_share_t)
5- install samba samba-client (to test local first)
6- copy smb.conf.example ==>smb.conf
7- edit config file (1-general config 2-logs config 3-securiy config 4-file
sharing services (win& linux) )
8- testparm
9-add service to firewall (samba)
10-enable and start services (nmb and smb)
11-test local and remotely
##on linux client
1- install samba-client and cifs-utils
2- view share using two commands (smbtree,smbclient)
3- mount -t cifs username,password
4- add fstab entry (presistent mount)
##on windows machine
1- connectto share from run (\\192.168.100.25)
2- login with username and password
3- map network drive
####config on server
mkdir /sambashare
chmod 777 /sambashare
mkdir /sambashare/sales
mkdir /sambashare/marketing
mkdir /sambashare/public
groupadd sales
groupadd marketing
chgrp sales /sambashare/sales/
chgrp marketing /sambashare/marketing
chmod 2770 /sambashare/marketing #(chmod g+s /sambashare/marketing) (note
777 in nfs)
chmod 2770 /sambashare/sales
#create users and assign users to group
useradd user1 && passwd user1
useradd user2 && passwd user2
useradd user3 && passwd user3
useradd user4 && passwd user4
gpasswd -M user1,user2 sales
gpasswd -M user3,user4 marketing
#selinux
semanage fcontext -a -t samba_share_t "/sambashare(/.*)?"
restorecon -Rv /sambashare/
ls -lZ /sambashare/
dnf install samba samba-client –y
cp /etc/samba/smb.conf.example /etc/samba/smb.conf
#edit config file
nano /etc/samba/smb.conf ##(sections)
###general config
workgroup = WORKGROUP
#server string = Samba Server Version %v (remove %v to hide version )
server string = Sharing Server
netbios name = server
interfaces = lo ens160 192.168.100.25/24
hosts allow = 127. 192.168.100.
###log config config
log file = /var/log/samba/log.%m
### Security Config
##Standalone Server Options
security = user
passdb backend = tdbsam #(as sam file)
##Browser control options:
#os level = determines the precedence the server has in master browser
# elections. The default value should be reasonable (nmb role)
local master = yes
os level = 60
preferred master = yes
***********************************************
Share Defination
[myshare] ==> what user will see
comment = welcome to my share ==> what the user will see
path = /sambashare/sales ==> location of the data
writable = yes ==> rw permission and need write list
write list = ali, @users, +users ==> users with write permission
vaild users = user3, @users ==> @ means a group or +groupname
***************private share****************************
[sales]
comment = sales group share
path = /sambashare/sales
writable = yes
write list = ali, @sales
valid users = @sales
[marketing]
comment = sales group share
path = /sambashare/marketing
writable = yes
write list = ali, @marketing
valid users = @marketing
**********public share*****************
[public]
comment = public group share
path = /sambashare/public
public = yes
browseable = yes
read only =no #==> means read/write
guest account = any #==> this account must be valid in /etc/passwd and
smbpasswd utility
guest ok = yes #==> //allow anonymous user to enter without username
and password and no password is required
******************************
[public]
comment = public group share
path = /sambashare/public
public = yes
browseable = yes
read only =no
#guest account = nobody
guest ok = yes
guest only = yes
guest ok = yes
guest account = nobody
#####################33
add users to samba database
smbpasswd -a user1
smbpasswd -a user2
smbpasswd -a user3
smbpasswd -a user4
####to see users pdbedit -L
******************************************
#firewall
firewall-cmd --add-service=samba --permanent
firewall-cmd --add-service=samba
#enable and Start services
systemctl enable --now smb.service nmb.service
***************************************
local test (smbclient -L netbiosname)
[user1@srv1 ~]# findsmb (print smb server info)
[user1@srv1 ~]# smbclient //server/public
Enter WORKGROUP\root's password:
Anonymous login successful
[user1@srv1 ~]$ smbclient //server/sales #require user1
passowrd
[user1@srv1 ~]$ smbclient //server/marketing -U user4
[user1@srv1 ~]$ smbclient -L server
***************************************************
note error messages
session setup failed: NT_STATUS_LOGON_FAILURE
tree connect failed: NT_STATUS_ACCESS_DENIED
### on client side
dnf install samba-client cifs-utils -y
smbclient //192.168.100.25/marketing -U user4
mount -t cifs -o username=user4,password=1 //192.168.100.25/marketing
/sambaclient/
nano /etc/fstab
//192.168.100.25/marketing /sambaclient cifs
defaults,username=user4,password=1 0 0
##access Without username and password (anonymous)
mount -t cifs -o sec=none //192.168.10.25/public /sambpub/
delete win cache
net use * /delete