一、共享主机(ubuntu)
1、sudo useradd auser
sudo mkdir /opt/share
sudo chmod 777 /opt/share
sudo chown -R auser:auser /opt/share
2、sudo apt-get update
sudo apt-get install samba
sudo vi /etc/samba/smb.conf
[global]
map to guest = bad user
guest account = auser
[share]
path = /opt/share
available = yes
browseable = yes
public = yes # 匿名
writeable = yes
force user = auser # 把文件属性 归属于auser
force group = auser # 把文件属性 归属于auser组
#guest ok = Yes # 匿名
#valid users = auser
3、sudo useradd auser
sudo smbpasswd -a auser
输入密码:123
4、sudo service smbd restart
5、有防火墙时
sudo ufw allow 'samba'
或
sudo ufw allow 137/138/139/445
或关闭
sudo ufw disable
二、访问主机(ubuntu)
1、sudo apt-get install cifs-utils
2、sudo mkdir /opt/share
3、sudo mount -t cifs //192.168.0.12/share /opt/share -o uid=1000,gid=1000
# uid、gid可以cat /etc/passwd 查询到。
# 如果匿名不用加 username=auser,password=123
4、ll /opt/share
5、sudo umount /opt/share