1. Samba用户的增删改查

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
创建用户,创建samba用户
[root@192 ~]# adduser --no-create-home -s /sbin/nologin user1
[root@192 ~]# pdbedit --create user1

查看用户:
[root@localhost ~]# pdbedit -L
chunli:1000:
root:0:root
[root@localhost ~]#

修改密码:
[root@localhost home]# smbpasswd chunli
[root@localhost home]# smbpasswd root

删除用户:
[root@localhost home]# pdbedit -x chunli
[root@localhost home]# pdbedit -x root


smbpasswd 也可以对用户增删改查

2. samba 配置 最佳实践

samba 公共配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@localhost ~]# cat /etc/samba/smb.conf
[global]
workgroup = SAMBA
keepalive = 3600
socket options = TCP_NODELAY IPTOS_LOWDELAY
#config file = /etc/samba/smb.conf.%U
include = /etc/samba/smb.conf.%U

# 公共 共享
[workspace]
path = /home/workspace/
writeable = yes
create mask = 0664
directory mask = 0775
[root@localhost ~]#

# config file 摒弃全局配置的共享,仅包含用户自己的配置。
# include 包含全局配置的共享,且包含用户自己的配置。
# config file 与 include 这两个值同时出现时,以第一个出现的为主,下面出现的被忽略。

#valid users = root,chunli #一旦配置了, 打开白名单模式
#valid users 如果不写本值, 默认允许所有的用户。

# writeable 默认值为 no
# browseable 默认值为 yes

单独配置 chunli 用户:

1
2
3
4
5
6
7
[root@localhost ~]# cat /etc/samba/smb.conf.chunli
[01_Disk]
path = /mnt/data/
writeable = no
create mask = 0664
directory mask = 0775
[root@localhost ~]#

单独配置 root 用户:

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@localhost ~]# cat  /etc/samba/smb.conf.root 
[02_Book]
path = /home/01_book/
writeable = yes
create mask = 0664
directory mask = 0775

[03_Work]
path = /home/02_work/
writeable = yes
create mask = 0664
directory mask = 0775
[root@localhost ~]#

chunli 用户的效果

root 用户的效果