安装Samba服务
sudo apt update -y
sudo apt install samba samba-common -y
新建Samba用户
sudo groupadd smb
sudo useradd -s /sbin/nologin -g smb huu
设置Samba用户密码
sudo smbpasswd -a huu
配置Samba
编辑文件sudo vi /etc/samba/smb.conf,添加内容,
[global]
workgroup = WORKGROUP
netbios name = NAS
server string = Samba Server
server string = NAS Samba Server TestServer
security = user
include = /etc/samba/%U.smb.conf
log file = /var/log/samba/%m.log
max log size = 5000
username map = /etc/samba/smbusers
unix charset = UTF-8
dos charset = CP936
display charset = UTF-8
hosts allow = 172.17.0.0/16 127.0.0.1
passdb backend = tdbsam
编辑文件sudo vi /etc/samba/huu.smb.conf,添加内容,
[MOVIE]
comment = MOVIE
path = /mnt/brook
writable = yes
read list = huu
write list = huu
browseable = yes
valid_user = huu
passdb backend = smbpasswd
create mask = 0777
directory mask = 0777
编辑文件sudo vi /etc/samba/smbusers,添加内容,
root = administrator admin huu
nobody = guest pcguest smbguest
启动Samba
sudo systemctl enable smbd
sudo systemctl restart smbd
ps aux | grep smb
sudo netstat -nltp | grep -iE "139|445"