(1)安装samba
sudo apt install samba
(2)添加用户
xiaxinkai@aliyun:/etc/samba$ sudo smbpasswd -a xiaxinkai
New SMB password:
Retype new SMB password:
Added user xiaxinkai.
(3)修改/etc/samba/smb.conf,在文件最底部加上共享目录信息
[xiaxinkai]
comment = Home Folder
path = /home/xiaxinkai
browseable = yes
read only = no
create mask = 0755
directory mask = 0755
valid users = xiaxinkai
到达此处,Ubuntu16.04已经能正常工作了。
但是Ubuntu18.04为什么还是连不上?
(4)Ubuntu18.04请在配置文件中加上【ntlm auth = yes】
位置就放在所有共享目录定义【Share Definitions】之前吧。
修改前:
# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
usershare allow guests = yes
#======================= Share Definitions =======================
修改后:
# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
usershare allow guests = yes
# Add by xiaxinkai
ntlm auth = yes
#======================= Share Definitions =======================
这个时候Ubuntu18.04就能正常访问samba共享文件夹了!
原因是Ubuntu16.04和18.04默认的samba版本不一样。
18.04的samba版本是4.7.6
xiaxinkai@aliyun:~$ samba --version
Version 4.7.6-Ubuntu
Samba为了提高安全性从版本4.5.0开始默认将ntlm auth选项默认从yes变更为no。
详细见Samba 4.5.0 Release History:
https://www.samba.org/samba/history/samba-4.5.0.html