Press "Enter" to skip to content

centos7部署samba服务

一,Samba共享服务的匿名访问

1,安装Samba服务

[root@localhost ~]# yum install samba -y ##安装Samba服务

复制

2,配置Samba配置文件信息

[root@localhost ~]# cd /etc/samba/  ##切换到Samba配置文件目录
[root@localhost samba]# mv smb.conf smb.conf.bak  ##备份
[root@localhost samba]# grep -v "#" smb.conf.bak > smb.conf  ##重新创建一个配置文件(除去注释的)
[root@localhost samba]# vim smb.conf  ##修改配置文件

[global]                   ##全局
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw
        map to guest = Bad User   ##添加此项,开启匿名用户访问

[public]                   ##添加的share文件
        path=/home/public            ##路径
        public=yes              ##公共访问
        browseable=yes          ##能够访问
        writable=yes             ##写权限
        create mask=0644        ##设置权限
        directory mask=0755

复制

3,创建myshare路径目录,并给权限

[root@localhost samba]# mkdir /home/public   ##创建目录
[root@localhost samba]# chmod 777 /home/public  ##给全部权限
[root@localhost samba]# systemctl stop firewalld.service  ##关闭防火墙
[root@localhost samba]# setenforce 0  ##关闭增强功能
[root@localhost samba]# systemctl start smb.service  ##开启Samba服务

二,Samba共享服务的身份验证

1,配置Samba配置文件信息

[root@localhost ~]# cd /etc/samba/  ##切换到Samba配置文件目录
[root@localhost samba]# vim smb.conf  ##修改配置文件

[global]
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw 
[share]
	path=/home/share
	browseable=yes
	writable=yes
	create mask=0644
	directory mask=0755
	valid users=admin
	write list=admin

2,创建smb用户

[root@localhost samba]# useradd admin   ##创建用户
[root@localhost samba]# smbpasswd -a admin  ##创建smb用户并设置密码
New SMB password:    ##设置密码
Retype new SMB password:   ##确认密码
Added user zhangsan.
[root@localhost samba]# pdbedit -L  ##列出smb用户列表
admin:1001:
[root@localhost samba]# cd /home/  
[root@localhost opt]# mkdir share  ##创建共享目录
[root@localhost opt]# ls
abc rh test
[root@localhost opt]# chmod 777 share/  ##给最大权限
[root@localhost opt]# systemctl restart smb.service  ##重启Samba服务

三,Samba服务启用回收站功能

[share]
	path=/home/share
	browseable=yes
	writable=yes
	create mask=0644
	directory mask=0755
	valid users=admin
	write list=admin

	vfs objects = recycle
	recycle:repository = .recycle
	recycle:keeptree = yes
	recycle:versions = yes

参考资料:

https://cloud.tencent.com/developer/article/1720995

https://unix.stackexchange.com/questions/112063/how-can-i-have-a-trash-recycle-bin-for-my-samba-shares

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注