I recently learned Linux and wanted to use RedHat Linux as a learning platform, but found that the RedHat Linux ISO file is too difficult to download. Because CentOS and RedHat Linux are very similar, I chose to download the CentOS Linux 7 DVD ISO. This image is more than 4 GB, but the download only took more than 30 minutes.
There are a lot of articles on configuring samba on the Internet, but I found that none of them can be implemented. So I decided to write a complete configuration. Although the security cannot be guaranteed, the function can be realized, and the security will be studied later.
-
Install
share name | path | permission |
SHAREDOC | /smb/docs | Accessible to all personnel including guests |
RDDOCS | /smb/tech | Allow read and write access only to specific groups of users |
准备工作:
创建共享目录(假设共享
/smb
目录下的文件)
# mkdir -p /smb/docs
# mkdir -p /smb/tech
//
创建操作系统用户
# useraddalice
# useraddjack
# useradd tom
# useradd RD
//
修改用户的组
# usermod -a-G RD alice
# usermod -a-G RD jack
# usermod -a-G RD tom
账号创建完以后检查用户所属组,确保每个用户所属组都有1003 RD
# id alice
uid=1000(alice) gid=1000(alice)
groups
=1000(alice),1003(RD)
# id jack
uid=1001(jack) gid=1001(jack)
groups
=1001(jack),1003(RD)
# id tom
uid=1002(tom) gid=1002(tom)
groups
=1002(tom),1003(RD)
# id RD
uid=1003(RD) gid=1000(RD)
groups
=1003(RD)
//
修改目录权限
# chgrp RD /smb/tech
# chgrp RD /smb/docs
# chown RD /smb/tech
# chown RD /smb/docs
# chmod 770 /smb/tech
# chmod 770 /smb/docs
修改完成后再检查一下文件夹权限
# ls /smb -l
//
备份原有的配置文件在原目录下
# cd /etc/samba
# cp smb.conf smb.conf.origin
# vi/etc/samba/smb.conf
删除原有所有内容,添加如下内容:
[global]
workgroup=BIGCLOUD
netbios name=ZZSRV2
server string=Samba Server
#security=share
security=user
map to guest = Bad User
[SHAREDOCS]
path=
/smb/docs
readonly
=
yes
browseable=
yes
guest ok=
yes
[RDDOCS]
path =
/smb/tech/
public = no
writable =
yes
write list = @RD
validusers = @RD