Linux系统之CIFS文件系统

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值