Linux实验07 Samba服务器配置

2024-04-19 10:54:15 浏览数 (2)

1.复制镜像

原Linux镜像改名为C100

复制生成一个新的Linux镜像,改名C101

2.设置虚拟机网络环境

网段:192.168.100.0

子网掩码:255.255.255.0

网关:192.168.100.2

3.配置网络

C100配置ip为192.168.100.100

C101配置ip为192.168.100.101

4.C100安装Samba

yum install samba -y

5.新建Samba用户(这里设置为123456)

smbpasswd -a root

6.新建目录设置权限

mkdir -p /data/web_data

setfacl -m u:root:rwx /data/web_data/

7.配置Samba服务器配置文件smb.conf

cd /etc/samba/

vim smb.conf

修改成如下

代码语言:javascript复制
[global]
        workgroup = WORKGROUP
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

# [homes] 
#       comment = Home Directories
#       valid users = %S, %D%w%S
#       browseable = No
#       read only = No
#       inherit acls = Yes

#[printers]   
#       comment = All Printers
#       path = /var/tmp
#       printable = Yes 
#       create mask = 0600
#       browseable = No

[webdata] 
        comment = webdata
        path = /data/web_data 
        browseable = Yes
        writable = Yes
        valid users = root
        host allow = 192.168.100.101
        host deny = all

按Esc,输入:wq保存退出

重启Samba服务

systemctl restart smb

8.C100中设置防火墙放行Samba服务

firewall-cmd --permanent --add-service=samba

firewall-cmd --reload

firewall-cmd --list-all

9.修改SELinux安全策略

setenforce 0

getenforce

10.使用C101访问C100

ping 192.168.100.100

smbclient -L 192.168.100.100 -U root3456

smbclient // 192.168.100.100/webdata -U root3456

0 人点赞