centos 7 配置samba服务器(用户认证)

一、配置samba
1、安装软件包

[root@smb ~]# yum -y install samba samba-client

2、创建组

[root@smb ~]# groupadd security

3、创建目录

[root@smb ~]# mkdir /home/security
[root@smb ~]# chgrp security /home/security
[root@smb ~]# chmod 770 /home/security

4、修改配置文件

[root@smb ~]# vi /etc/samba/smb.conf
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
        workgroup = WORKGROUP
	security = user

	passdb backend = tdbsam

	printing = cups
	printcap name = cups
	load printers = yes
	cups options = raw
        unix charset = UTF-8

[homes]
	comment = Home Directories
	valid users = %S, %D%w%S
	browseable = No
	read only = No
	inherit acls = Yes

[printers]
	comment = All Printers
	path = /var/tmp
	printable = Yes
	create mask = 0600
	browseable = No

[print$]
	comment = Printer Drivers
	path = /var/lib/samba/drivers
	write list = @printadmin root
	force group = @printadmin
	create mask = 0664
	directory mask = 0775
[Security]# any name you like
        path = /home/security
        writable = yes
        create mode = 0770
        directory mode = 0770
        guest ok = no
        valid users = @security

5、启动服务,并设置开机启动

[root@smb ~]# systemctl start smb nmb
[root@smb ~]# systemctl enable smb nmb

6、添加用户

add a user in Samba

[root@smb ~]# useradd cent -g security -s /sbin/nologin
[root@smb ~]# smbpasswd -a cent
New SMB password: # set password
Retype new SMB password: # confirm
Added user cent.

如有多个用户请重复操作该步骤
7、配置防火墙

[root@smb ~]# firewall-cmd --add-service=samba --permanent
success
[root@smb ~]# firewall-cmd --reload
success

8、配置selinux

[root@smb ~]# setsebool -P samba_enable_home_dirs on
[root@smb ~]# restorecon -R /home/security

二、在客户端挂载
1、安装软件包

# yum install –y cifs-utils samba-client

2、创建挂载目录

# mkdir /mnt/dev

3、查询详情

# smbclient -L /172.16.30.161/ -U cent

4、更新fstab

//172.16.30.161/home/security /mnt/dev cifs defaults,multiuser,username=cent,password=redhat,sec=ntlmssp 0 0

5、挂载

# mount -a
mount.cifs \\\\192.10.10.18\\backup /share -o username=guest,pass="Condata@123",uid=500,gid=600

你可能感兴趣的:(RHCE操作系统)