rpm -qa | grep sambaUbuntu:dpkg -l | grep samba
yum install samba samba-client samba-commonsudo apt-get install -y samba samba-clientcp /etc/samba/smb.conf /etc/samba/smb.conf.backup):sudo vim /etc/samba/smb.conf [myshare]
comment = share all
path = /opt/mysamba #分享的目录,其中这个目录需要chmod 777 /opt/mysamba权限
browseable = yes
writable = yes
public =yes
useradd user1,再用samba的设置添加账号:pdbedit -a user1,会让你设立该samba账号密码。列出账号:pdbedit -L
[myshare2]
comment = share for users
path = /opt/mysamba2 #分享的目录,其中这个目录需要chmod 777 /opt/mysamba权限
# (不一定要 777 权限,只要登录 samba 的用户是这个目录的用户即可,那么在 Windows 中的文件创建和写入都等同于 linux 的等价账户)
browseable = yes
writable = yes
public = no
read only = no
guest ok = no # samba 4 拥有的
create mask = 0646
force create mode = 0646
directory mask = 0747
force directory mode = 0747
[global]
workgroup = WORKGROUP
passdb backend = tdbsam
printing = cups
printcap name = cups
printcap cache time = 750
cups options = raw
map to guest = Bad User
include = /etc/samba/dhcp.conf
logon path = \\%L\profiles\.msprofile
logon home = \\%L\%U\.9xprofile
logon drive = P:
max connections = 0
deadtime = 0
max log size = 500
[share1]
path = /home/<your path>
browsable =yes
writable = yes
read only = no
guest ok=no
create mask = 0646
force create mode = 0646
directory mask = 0747
force directory mode = 0747
sudo service samba restartservice smb restart # 启动 sambasystemctl start smb.service # 启动 sambasystemctl enable smb.service # 激活systemctl status smb.service # 查询 samba 状态(启动 samba 前后可以用查询验证)sudo service smbd restart在 Windows 连接 Samba 之前,可在本地(linux)使用命令验证
smbclient –L //localhost/<your samba share label> -U <your samba user>
接下来输入的 password 来自于 pdbedit -a user1 命令为该用户设置的密码,不一定是 linux 用户密码
Windows 登录
打开资源管理器 -> 映射网络驱动器 -> 文件夹 填写上述 smbclient –L 命令后面加的路径 ->
弹出用户名密码对话框 -> 登录成功
linux 防火墙
Windows 用户密码都正确,错误提示‘未知的用户名和密码。’ regedit 打开注册表,删除键值 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa 中的 LMCompatibilityLevel,无需重启计算机