Samba


    1. Samba 介绍

      Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成。SMB(Server Messages Block,信息服务块)是一种在局域网上共享文件和打印机的一种通信协议,它为局域网内的不同计算机之间提供文件及打印机等资源的共享服务。SMB协议是客户机/服务器型协议,客户机通过该协议可以访问服务器上的共享文件系统、打印机及其他资源。通过设置“NetBIOS over TCP/IP”使得Samba不但能与局域网络主机分享资源,还能与全世界的电脑分享资源。

    2. Samba的匿名访问 (三台PC,LINUXserver,LINUXclient,windows10)

    3. Samba的本地认证访问


  1. a.匿名访问配置

1.服务器上的配置

server# systemctl stop firewalld
server# setenforce 0
server# yum install samba* -y
server# vim /etc/samba/smb.conf   ##(在全局配置下添加map to guest = Bad User   ,   其余是新模块里面添加)
[share]
	comment = share
	path = /share
	browseable = yes
	public = yes
	writable = yes
	guest ok = yes
server# mkdir /share 
server# chmod 777 /share
server# systemctl enable smb nmb
server# systemctl restart smb nmb


2.LINUX客户端配置  + (成功截图)

client# yum install samba-client cifs-utils -y
client# mount -t cifs -o username='Bad User' //172.16.30/46/share /mnt
client# df -h

image.png

WINDOWS 10 ctrl+e 输入 \\172.16.30.46  

image.png


b使用本地认证

    1.服务端配置

server# systemctl stop firewalld
server# setenforce 0
server# yum install samba* -y
server# useradd -M tom
server# smbpasswd -a tom
server# echo "tom=runtime"
server# vim /etc/samba/smb.conf   ##(在全局配置下添加 username map = /etc/samba/user  ,   其余是新模块里面添加)
[shares]
	comment = share
	path = /shares
	browseable = yes
	public = yes
	writable = yes
	write list = tom
	guest ok = yes
server# mkdir /shares 
server# chmod 777 /shares
server# systemctl enable smb nmb
server# systemctl restart smb nmb

2.客户端配置

client# yum install samba-client cifs-utils -y
client# mount -t cifs -o username='tom',password='123456' //172.16.30.46/shares /mnt
client# df -h

image.pngimage.png




目标server和client服务

在server上配置SAMBA服务

server# yum install samba* -y
server# mkdir /common /storage
server# firewall-cmd --add-rich-rule 'rule family=ipv4 source address=172.16.30.0/24 service name=samba accept' --permanent
server# firewall-cmd --add-rich-rule 'rule family=ipv4 source address=172.16.30.0/24 service name=samba-client accept' --permanent
server# firewall-cmd --reload
server#  setsebool -P samba_enable_home_dirs on
server# chcon  -Rt samba_share_t /common
server# chcon  -Rt samba_share_t /storage
server#  useradd natasha
server#  useradd sarah
server#  useradd kitty
server#  smbpasswd natasha
server#  smbpasswd sarah
server#  smbpasswd kitty

    配置serverSAMBA的服务器

server# vim /etc/samba/smb.conf
workgroup = MYGROUP

[common]
        path = /common
        browseable = yes
        valid users = natasha

[share]
        path = /storage
        browseable = yes
        valid users = kitty,sarah
        write list = kitty
        writable = no
server# systemctl restart smb nmb
server# systemctl enable  smb nmb
server# setfacl -m u:natasha:r-x /common
server# setfacl -m u:sarah:r-x /storage
server# setfacl -m u:kitty:rwx /storage

2.客户端

yum install smb-client cifs-utils -y
mount //172.16.30.30/common /mnt/dev  -o  username=natasha,password=tangkai
mount //172.16.30.30/share /mnt/dev2  -o  username=sarah,password=tangkai
mount //172.16.30.30/share /mnt/dev2  -o  username=kitty,password=tangkai
vim /etc/fstab
//172.16.30.30/share /mnt/dev	cifs	multiuser,username=sarah,password=tangkai,sec=ntlmssp 0 0

useradd tom
su - tom
cd /mnt/dev2
touch 2   ##(发现权限被拒绝)
cifscreds  add -u kitty 172.16.30.30
cd /mnt/dev2
touch 222   ##(成功)







發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章