Debian 使用 Samba 服务为 Windows 客户端和 Linux 客户端提供文件服务

1 目标

1.1 主机采用 Debian,为 Windows 和 Liunx 客户端提供文件存取服务

1.2 Windows 采用 GB2312 编码,Linux 采用 UTF-8 编码,要求中文不出现乱码

1.3 客户端认证用户名: share 密码:share

1.4 客户端可读可写,相互之间可修改

1.5 假定 Samba 服务器 IP:192.168.10.200

2 服务端

2.1 安装 Samba 服务

$ sudo apt install samba

2.2 配置

2.2.1 新增认证用户

$sudo useradd share -s /bin/false -d /dev/null

$sudo passwd share //设置 share 的密码

2.2.2 配置编码

$sudo dpkg-reconfigure locales  //增加 zh_GB2312 locale

$sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

$sudo grep -vE "^#|^;|^$" /etc/samba/smb.conf.bak > /etc/samba/smb.conf

$sudo vim /etc/samba/smb.conf

在 [global] section 中加入

dos charset = GB2312

unix charset = UTF-8

2.2.3 增加共享 section

[share]

comment = Provides Filesystem For Anyone

path = /share

browsable = yes

create mask = 0777

directory mask = 0777

read only = no

writable = yes

guest ok = yes

public = yes

2.2.4 创建共享目录并设置权限

$ sudo mkdir /share

$ sudo chmod -R 0777 /share

3 客户端

3.1 Linux

$ sudo apt install smbclient

3.2 Windows

打开我的电脑,地址栏输入 \192.168.10.200

建议:可以 map as a disk

原文地址:https://www.cnblogs.com/mouseleo/p/10704084.html