安装smaba
[root@localhost html]# yum -y install samba*
配置samba
[root@localhost opt]# tail -n 7 /etc/samba/smb.conf
[hmmm]
comment = hmmmm
browseable = YES
path = /opt/samba
write list = hmmm
valid users = hmmm,hhhh
重启服务
[root@localhost opt]# systemctl restart smb
创建共享文件
[root@localhost opt]# mkdir /opt/samba
# 给读写权限
[root@localhost opt]# chmod 777 /opt/samba
创建用户
# 创建普通用户
[root@localhost opt]# useradd hmmm
[root@localhost opt]# echo qwe|passwd --stdin hmmm
[root@localhost opt]# useradd hhhh
[root@localhost opt]# echo qwe|passwd --stdin hhhh
#创建smb用户
[root@localhost opt]# smbpasswd -a hmmm //回车之后输入密码
[root@localhost opt]# smbpasswd -a hhhh //回车之后输入密码
防火墙放行
[root@localhost html]# firewall-cmd --permanent --add-service=samba
success
[root@localhost html]# firewall-cmd --reload
success
[root@localhost html]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens160
sources:
services: cockpit dhcpv6-client ftp http samba ssh
ports:
protocols:
forward: yes
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
seinux放行
[root@localhost html]# setsebool -P samba_domain_controller on
[root@localhost html]# setsebool -P samba_enable_home_dirs on
[root@localhost html]# chcon -t samba_share_t /opt/samba/
[root@localhost html]# setsebool -P samba_export_all_rw on
测试
[root@node1 ~]# smbclient -L //192.168.130.10/hmmm --user=hmmm
Password for [SAMBA\hmmm]:
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
hmmm Disk hmmmm
IPC$ IPC IPC Service (Samba 4.15.5)
SMB1 disabled -- no workgroup available
[root@node1 ~]# mount -t cifs //192.168.130.10:/hmmm -o username=hmmm,password=qwe -l /mnt/share
[root@node1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 941M 0 941M 0% /dev
tmpfs 971M 0 971M 0% /dev/shm
tmpfs 389M 11M 378M 3% /run
/dev/mapper/rhel-root 46G 4.2G 42G 10% /
/dev/nvme0n1p1 495M 221M 275M 45% /boot
tmpfs 195M 116K 194M 1% /run/user/0
/dev/sr0 8.0G 8.0G 0 100% /media
//192.168.130.10:/hmmm 46G 4.3G 42G 10% /mnt/share
[root@node1 ~]# cd /mnt/share/
[root@node1 share]# ls
llll
[root@node1 share]# mkdir huhuhu
[root@node1 share]# ls
huhuhu llll
[root@node1 share]#
标签:opt,samba,服务,--,root,localhost,hmmm
From: https://www.cnblogs.com/humlogs/p/18186671