centos7 nas
关闭selinux
编辑 /etc/selinux/config,将SELinux属性设置为Disabled,如下所示:
1[root@localhost ~]# vi /etc/selinux/config
2
3# This file controls the state of SELinux on the system.
4# SELINUX= can take one of these three values:
5# enforcing - SELinux security policy is enforced.
6# permissive - SELinux prints warnings instead of enforcing.
7# disabled - No SELinux policy is loaded.
8# SELINUX=enforcing
9SELINUX=disabled
10# SELINUXTYPE= can take one of three two values:
11# targeted - Targeted processes are protected,
12# minimum - Modification of targeted policy. Only selected processes are protected.
13# mls - Multi Level Security protection.
14SELINUXTYPE=targeted
重启使之生效
关闭防火墙
1systemctl stop firewalld
安装samba
1yum install samba -y
安装包说明
samba-common-3.5.10-125.el6.x86_64 //主要提供samba服务器的设置文件与设置文件语法检验程序testparm
samba-client-3.5.10-125.el6.x86_64 //客户端软件,主要提供linux主机作为客户端时,所需要的工具指令集
samba-swat-3.5.10-125.el6.x86_64 //基于https协议的samba服务器web配置界面
samba-3.5.10-125.el6.x86_64 //服务器端软件,主要提供samba服务器的守护程序,共享文档,日志的轮替,开机默认选项
查看samba服务状态
1[root@localhost ~]# systemctl status smb
2● smb.service - Samba SMB Daemon
3 Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
4 Active: inactive (dead)
5 Docs: man:smbd(8)
6 man:samba(7)
7 man:smb.conf(5)
设置samba开机启动
1[root@localhost ~]# systemctl enable smb
2Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
启动samba服务
1[root@localhost ~]# systemctl start smb
配置服务
安装后会生成/etc/samba目录,配置文件是/etc/samba/smb.conf
1# See smb.conf.example for a more detailed config file or
2# read the smb.conf manpage.
3# Run 'testparm' to verify the config is correct after
4# you modified it.
5
6[global]
7 workgroup = WORKGROUP # 设置成 Windows 的工作组
8 security = user # 安全选项,可以是 share|user|server|domain,安全级别递增
9
10 passdb backend = tdbsam
11
12 printing = cups
13 printcap name = cups
14 load printers = yes
15 cups options = raw
16
17[homes] # 共享默认会将用户的主目录共享 , 这是不安全的 , 可以将其注释
18 comment = Home Directories
19 valid users = %S, %D%w%S
20 browseable = No
21 read only = No
22 inherit acls = Yes
23
24[printers] # 打印机共享
25 comment = All Printers
26 path = /var/tmp
27 printable = Yes
28 create mask = 0600
29 browseable = No
30
31[print$]
32 comment = Printer Drivers
33 path = /var/lib/samba/drivers
34 write list = @printadmin root
35 force group = @printadmin
36 create mask = 0664
37 directory mask = 0775
38
39[shared] # 自定义共享的文件夹名称,名字随意
40 comment = Guest Directory
41 path = /home/guest/samba # 共享的路径
42 writeable = yes
43 browsable = yes
44 public = yes
创建linux用户,然后更改用户密码
1[root@localhost samba]# useradd guest
2[root@localhost samba]# passwd guest
3更改用户 guest 的密码 。
4新的 密码:
5无效的密码: 密码少于 8 个字符
6重新输入新的 密码:
7passwd:所有的身份验证令牌已经成功更新。
创建samba用户(添加的账户必须linux已经创建的)
1[root@localhost samba]# smbpasswd -a guest
2New SMB password:
3Retype new SMB password:
4Added user guest.
Samba 用户操作的命令:
1// 添加 Samba 用户帐号
2[root@localhost samba]# smbpasswd -a sambauser
3
4// 修改 Samba 用户密码(需两次输入相同密码)
5[root@localhost samba]# smbpasswd sambauser
6
7// 禁用 Samba 用户帐号
8[root@localhost samba]# smbpasswd -d sambauser
9
10// 启用 Samba 用户帐号
11[root@localhost samba]# smbpasswd -e sambauser
12
13// 删除 Samba 用户帐号
14[root@localhost samba]# smbpasswd -x sambauser
15
16// 查询系统中已存在的用户帐号
17[root@localhost samba]# pdbedit -L
pdbedit是samba的用户管理命令
常用参数:
新建Samba账户:
[root@linuxcool ~]# pdbedit -a linuxcool
修改Samba账户:
[root@linuxcool ~]# pdbedit -r linuxprobe
删除Samba账户:
[root@linuxcool ~]# pdbedit -x linuxcool
列出Samba用户列表详细信息:
[root@linuxcool ~]# pdbedit -Lv
添加共享文件夹(在smb.conf中指定好了的)
1mkdir /home/guest/samba
2chown -R guest:guest /home/guest/samba
重启samba服务
1[root@localhost samba]# systemctl restart smb
测试
smbclient //192.168.0.180/shared2 –user=用户名%密码
评论