CIFS文件系统
搭建samba服务器
环境:安装samba,samba-common,samba-client三个软件包
samba:这个套件主要包含了 SAMBA 的主要 daemon档案 ( smbd 及 nmbd )、 SAMBA 的文件档 ( document )、以及其它与 SAMBA 相关的logrotate 设定文件及开机预设选项档案等;
samba-common:这个套件则主要提供了 SAMBA 的主要设定档(smb.conf) 、 smb.conf 语法检验的测试程序 ( testparm )等等;
samba-client:这个套件则提供了当 Linux 做为SAMBA Client 端时,所需要的工具指令,例如挂载 SAMBA 档案格式的执行档
##安装软件
[root@samba0 ~]# yum install samba samba-common samba-client.x86_64 -y
[root@samba0 ~]# systemctl start smb
[root@samba0 ~]# systemctl enable smb
ln -s ‘/usr/lib/systemd/system/smb.service’ ‘/etc/systemd/system/multi-user.target.wants/smb.service’
[root@samba0 ~]# rpm -qa | grep samba
samba-4.1.1-31.el7.x86_64
samba-common-4.1.1-31.el7.x86_64
samba-libs-4.1.1-31.el7.x86_64
samba-client-4.1.1-31.el7.x86_64
[root@samba0 ~]# systemctl stop firewalld.service
[root@samba0 ~]# netstat -antlupe | grep smb
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 0 60346 2979/smbd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 0 60347 2979/smbd
tcp6 0 0 :::445 :::* LISTEN 0 60344 2979/smbd
tcp6 0 0 :::139 :::* LISTEN 0 60345 2979/smbd
##samba关于selinux的设置
如果selinux是开启状态,必须更改samba共享目录的安全上下文 samba_share_t
如果共享的目录除了SAMBA,还包括FTP或者其它服务,那么对于其他用户使用public_content_t
##建立sam用户
[root@samba0 ~]# pdbedit -L
[root@samba0 ~]# useradd westos
[root@samba0 ~]# smbpasswd -a westos
New SMB password:
Retype new SMB password:
Added user westos.
[root@samba0 ~]# pdbedit -L
westos:1001:
名称 | 方法 |
---|---|
建立sam用户 | smbpasswd -a |
冻结sam用户 | smbpasswd -d |
恢复sam用户 | smbpasswd -e |
设置sam用户密码为空 | smbpasswd -n |
删除sam用户 | smbpasswd -x |
这种删除删除的只是samba中的用户,而不是系统用户
在测试端:
[root@samba_client ~]# yum install samba-client.x86_64 -y
[root@samba_client ~]# smbclient -L //172.25.254.108
[root@samba_client ~]# smbclient //172.25.254.108/westos -U westos
[root@samba_client ~]# mount //172.25.254.108/westos /mnt -o username=westos,password=123
[root@samba_client ~]# cd /mnt
[root@samba_client mnt]# ls
file1 file2 file3 file4
samba服务配置及权限的更改
红帽版本7.0samba主配置文件:/etc/sysconfig/autofs
红帽版本7.2以上:/etc/autofs.conf
##域名的修改
[root@samba0 ~]# vim /etc/samba/smb.conf
workgroup = westos
[root@samba0 ~]# systemctl restart smb
测试:
[root@samba_client mnt]# smbclient -L //172.25.254.108 -U westos