linux服务器搭建samba共享样例,通过windows登录共享

发布时间 2023-10-10 14:34:48作者: DidierFeng

1. 关闭防火墙、selinux

1.1. 关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

1.2. 禁用selinux

1.2.1 关闭

setenforce 0

1.2.2 禁用

vim /etc/sysconfig/selinux
SELINUX=disabled

1.2.3 查看selinux状态

getenforce

2. 下载samba服务端

yum install -y samba
systemctl start smb

3. 创建共享路径

mkdir /storage/share
chmod 777 /storage/share

4. 添加用户、组

4.1. 在Linux中添加组

groupadd samba_group

4.2. 在Linux中添加用户

useradd -d /home/testuser -s /sbin/nologin testuser

4.3. 用户绑定组

usermod -aG samba_group testuser

4.4. 在samba中添加用户

smbpasswd -a testuser

4.5. 查看samba的用户

pdbedit -L

4.6. 查看组、用户

4.6.1. 查看组

cat /etc/group

4.6.2. 查看用户

cat /etc/passwd

5. 修改smb.conf文件(样例)

[share] //共享文件夹标识,登录samba时显示的路径名称。
comment = wo can share files in this directory
path = /storage/share
public = no //是否可公开
writable = yes //是否可写入
valid users = @samba_group,testuser //是否写入

6. 重启samb服务端

systemctl restart smb

7. windows登录共享

7.1. 清空原始共享信息

net use * /delete

7.2. 登录共享

\\共享地址\share