Skip to content

Commit dea6bb8

Browse files
authored
Merge pull request judasn#32 from fooofei/master
update samba
2 parents edbd22e + 97cf19e commit dea6bb8

File tree

1 file changed

+89
-4
lines changed

1 file changed

+89
-4
lines changed

Samba.md

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@
88
- Ubuntu:`dpkg -l | grep samba`
99

1010
- 安装:
11-
- CentOS 6:`XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`
11+
- CentOS 6:`yum install samba samba-client samba-common`
1212
- Ubuntu:`sudo apt-get install -y samba samba-client`
1313

1414
## Samba 服务器配置文件常用参数
1515

16-
- 配置文件介绍(记得先备份):`sudo vim /etc/samba/smb.conf`
16+
- 配置文件介绍(记得先备份 `cp /etc/samba/smb.conf /etc/samba/smb.conf.backup`):`sudo vim /etc/samba/smb.conf`
1717
- 该配置解释:
18-
-[globle] 区域
19-
- workgroup = WORKGROUP #WORKGROUP表示Windows默认的工作组名称,一般共享给windows是设置为WORKGROUP
18+
-[global] 区域
19+
- workgroup = WORKGROUP #WORKGROUP表示Windows默认的工作组名称,一般共享给windows是设置为WORKGROUP,此字段不重要,无需与 Windows 的域保持一致
2020
- security = user #ubuntu下配置文件默认没有这句,这个是自己填上去的。表示指定samba的安全等级,安全等级分别有四种:share(其他人不需要账号密码即可访问共享目录)、user(检查账号密码)、server(表示检查密码由另外一台服务器负责)、domain(指定Windows域控制服务器来验证用户的账号和密码)
21+
注: samba 4 不再支持 security = share (查看版本 smbd --version)
2122
- 在新区域区域
2223
- 当 security = share 使用下面这段,这段自己添加的,其中myshare这个名字表示其他机子访问该分享地址时用:file://该服务机IP/myshare
2324
```
@@ -34,16 +35,100 @@
3435
[myshare2]
3536
comment = share for users
3637
path = /opt/mysamba2 #分享的目录,其中这个目录需要chmod 777 /opt/mysamba权限
38+
# (不一定要 777 权限,只要登录 samba 的用户是这个目录的用户即可,那么在 Windows 中的文件创建和写入都等同于 linux 的等价账户)
3739
browseable = yes
3840
writable = yes
3941
public = no
42+
read only = no
43+
guest ok = no # samba 4 拥有的
44+
create mask = 0646
45+
force create mode = 0646
46+
directory mask = 0747
47+
force directory mode = 0747
4048
```
49+
50+
- 一份成功的 samba 4 配置
51+
```
52+
[global]
53+
workgroup = WORKGROUP
54+
passdb backend = tdbsam
55+
printing = cups
56+
printcap name = cups
57+
printcap cache time = 750
58+
cups options = raw
59+
map to guest = Bad User
60+
include = /etc/samba/dhcp.conf
61+
logon path = \\%L\profiles\.msprofile
62+
logon home = \\%L\%U\.9xprofile
63+
logon drive = P:
64+
max connections = 0
65+
deadtime = 0
66+
max log size = 500
67+
[share1]
68+
path = /home/<your path>
69+
browsable =yes
70+
writable = yes
71+
read only = no
72+
guest ok=no
73+
create mask = 0646
74+
force create mode = 0646
75+
directory mask = 0747
76+
force directory mode = 0747
77+
```
4178
- 启动服务:
4279
- `sudo service samba restart`
80+
- `systemctl start smb.service` # 启动 samba
81+
- `service smb restart` # 启动 samba
82+
- `systemctl enable smb.service` # 激活
83+
- `systemctl status smb.service` # 查询 samba 状态(启动 samba 前后可以用查询验证)
84+
85+
86+
## Samba 登录及验证
87+
88+
- 在 Windows 连接 Samba 之前,可在本地(linux)使用命令验证
89+
90+
`smbclient –L //localhost/<your samba share label> -U <your samba user>`
91+
接下来输入的 password 来自于 `pdbedit -a user1` 命令为该用户设置的密码,不一定是 linux 用户密码
92+
<your samba share label> 来自 `/etc/samba/smb.conf` 文件中的标签,如上面的例子中有 `//localhost/myshare2`
93+
94+
提示如下面,表示 Samba 服务启动成功
95+
```
96+
Domain=[xxx1] OS=[Windows 6.1] Server=[Samba 4.6.2]
97+
98+
Sharename Type Comment
99+
--------- ---- -------
100+
share1 Disk
101+
IPC$ IPC IPC Service (Samba 4.6.2)
102+
Domain=[xxx1] OS=[Windows 6.1] Server=[Samba 4.6.2]
103+
104+
Server Comment
105+
--------- -------
106+
107+
Workgroup Master
108+
--------- -------
109+
xxx2 xxx1
110+
WORKGROUP xxx3
111+
112+
```
113+
- Windows 登录
114+
打开资源管理器 -> 映射网络驱动器 -> 文件夹 填写上述 `smbclient –L` 命令后面加的路径 ->
115+
弹出用户名密码对话框 -> 登录成功
116+
117+
118+
## Samba 登录失败
119+
120+
- linux 防火墙
121+
122+
- Windows 用户密码都正确,错误提示‘未知的用户名和密码。’
123+
regedit 打开注册表,删除键值 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa 中的 LMCompatibilityLevel,无需重启计算机
43124
44125
## Samba 资料
45126
46127
- <http://www.lvtao.net/linux/555.html>
47128
- <https://www.centos.bz/2011/07/centos5-install-samba-windows-linux-fileshare/>
48129
- <https://wsgzao.github.io/post/samba/>
49130
- <http://linux.vbird.org/linux_server/0370samba.php>
131+
- <https://www.liberiangeek.net/2014/07/create-configure-samba-shares-centos-7/>
132+
- <https://superuser.com/questions/1125438/windows-10-password-error-with-samba-share>
133+
- <https://github.com/SeanXP/README.md/tree/master/samba>
134+
- <http://www.apelearn.com/bbs/study/23.htm>

0 commit comments

Comments
 (0)