Linux工程技术中心,LINUX系统工程师技术(Engineer)-------第四天

两台虚拟机,均要检测

1. Yum是否可用

2. ?防火墙默认区域修改为trusted

3. IP地址是否配置

####################################################

? samba 文件共享(共享文件夹)

? Samba 软件项目

– 用途:为客户机提供共享使用的文件夹

– 协议:SMB(TCP 139)、CIFS(TCP 445)

? 所需软件包:samba

? 系统服务:smb

一、搭建基本samba服务

1.安装samba软件包

2.创建samba的共享帐号。与系统相同用户名,不同密码

[[email protected] ~]# useradd -s /sbin/nologin harry

[[email protected] ~]# useradd -s /sbin/nologin kenji

[[email protected] ~]# useradd -s /sbin/nologin chihiro

[[email protected] ~]# pdbedit -a harry ? ?#添加samba帐号,设置密码

[[email protected] ~]# pdbedit -a kenji ? ?#添加samba帐号,设置密码

[[email protected] ~]# pdbedit -a chihiro ?#添加samba帐号,设置密码

[[email protected] ~]# pdbedit -L ? ? ? ?#列出所有有效的samba帐号

3.修改服务配置文件 /etc/samba/smb.conf

?

? ?补充:vim ? 末行模式 ? ?set ?nu ?添加行号

? ? 89行 ? ? ? ? ?workgroup = STAFF

? ? 321行 ? ? [common] ? ? ? ? ? ? ? ? ? ? ? ? ?#共享名

? ? 322行 ? ? ? ?path = /common ? ? ?#共享实际路径

[[email protected] ~]# mkdir /common

[[email protected] ~]# echo haha > /common/abc.txt

4. 重起smb服务,设置为开机自起

虚拟机Desktop0

? 所需软件包:samba-client

[[email protected] ~]# smbclient -L //172.25.0.11

Enter root‘s password:?

[[email protected] ~]# smbclient -U harry //172.25.0.11/common

Enter harry‘s password:?

Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

NT_STATUS_ACCESS_DENIED listing \*

思路:客户端访问服务端资源

? ? 1.防火墙是否限制

? ? 2.服务本身的访问控制

? 3.SELinux 是否限制?

? SELinux: ?布尔值 ?(功能的开关)--------列如on和off,no和yes

? getsebool 查看 SELinux 开关

[[email protected] ~]# getsebool -a | grep samba

samba_export_all_ro --> off

samba_export_all_rw --> off

? setsebool 控制 SELinux 开关

– 需要加 -P 选项才能实现永久设置

[[email protected] ~]# setsebool ?samba_export_all_ro=on

[[email protected] ~]# getsebool -a | grep samba

虚拟机Desktop0

[[email protected] ~]# smbclient -U harry //172.25.0.11/common

Enter harry‘s password:?

Domain=[STAFF] OS=[Unix] Server=[Samba 4.1.1]

smb: \> ls

? 所需软件包:cifs-utils-----客户端

? _netdev: 开启网络服务后在改在该设备

1.安装软件包cifs-utils

2.修改/etc/fstab

//172.25.0.11/common /mnt/samba cifs user=harry,pass=123,_netdev 0 ?0

#mkdir /mnt/samba cifs

3. mount -a ?验证

? ?df ? -h

########################################################

?Samba读写的共享

1.修改配置文件/etc/samba/smb.conf

?[devops]

? ?path = /devops

? ?write list = chihiro

[[email protected] /]# mkdir /devops

[[email protected] /]# echo hahaxixi > /devops/123.tx

2.重起smb服务

3.客户端验证:

[[email protected] ~]# smbclient ?-L ? 172.25.0.11

Enter root‘s password:?

4.客户端挂载验证

[[email protected] ~]# mkdir /mnt/dev

[[email protected] ~]# vim /etc/fstab?

//172.25.0.11/devops /mnt/dev cifs user=chihiro,pass=123,_netdev 0 ?0

##################################################

实现读写Samba共享的其他操作

思路:客户端访问服务端资源

? ? 1.防火墙是否限制

? ? 2.服务本身的访问控制

? 3.SELinux 是否限制?

? ? 4. 服务端目录本地权限

一、修改服务端SELinux布尔值,开放读写

[[email protected] /]# getsebool -a | grep samba

[[email protected] /]# setsebool samba_export_all_rw=on

[[email protected] /]# getsebool -a | grep samba

二、目录本地权限

[[email protected] /]# ls -ld /devops/

[[email protected] /]# setfacl -m u:chihiro:rwx /devops/-----指针对一个人而用,chmod是针对所有人可用

[[email protected] /]# getfacl ? /devops/

三、客户端验证

[[email protected] ~]# touch /mnt/dev/test.txt

########################################################

?multiuser多用户访问(了解)

– multiuser,提供对客户端多个用户身份的区分支持

– sec=ntlmssp,提供NT局域网管理安全支持

客户端完成:

[[email protected] /]# vim ?/etc/fstab

//172.25.0.11/devops /mnt/dev cifs user=kenji,pass=123,_netdev,multiuser,sec=ntlmssp 0 ?0

[[email protected] /]# umount /mnt/dev/

[[email protected] /]# su - student

[[email protected] dev]$ cd /mnt/dev

[[email protected] dev]$ cifscreds add -u chihiro 172.25.0.11

Password:?

[[email protected] dev]$ touch abc.txt

#########################################################

?配置NFS共享-----------网络文件系统用于linux系统之间

? Network File System,网络文件系统

– 用途:为客户机提供共享使用的文件夹

– 协议:NFS(TCP/UDP 2049)、RPC(TCP/UDP 111)

? 所需软件包: nfs-utils

? 系统服务: nfs-server

搭建基本的只读NFS服务

1.在虚拟机server0上,检测nfs-utils是否安装

[[email protected] /]# rpm -q nfs-utils

2.修改配置文件/etc/exports

[[email protected] /]# mkdir /public

[[email protected] /]# echo hehelele > /public/nsd.txt

[[email protected] /]# vim /etc/exports

/public ? 172.25.0.0/24(ro)

?

3.重起nfs-server服务,设置开机自起

[[email protected] /]# systemctl restart ?nfs-server

[[email protected] /]# systemctl enable ?nfs-server

4.客户端 ?访问nfs-server服务

[[email protected] /]# mkdir /mnt/nfs

[[email protected] /]# showmount -e 172.25.0.11-------查看有哪些共享服务

[[email protected] /]# vim /etc/fstab?

?172.25.0.11:/public /mnt/nfs ?nfs ?_netdev 0 0

[[email protected] /]# ls ?/mnt/nfs

#######################################################

? 读写nfs-server服务

一.客户端root用户的读写

服务端:

[[email protected] /]# echo 123 > /abc/a.txt

[[email protected] /]# vim /etc/exports

? /abc ? 172.25.0.0/24(rw)

[[email protected] /]# systemctl restart nfs-server

客户端:

[[email protected] /]# vim /etc/fstab?

172.25.0.11:/abc /mnt/nsd ?nfs ?_netdev 0 0

[[email protected] /]# mkdir /mnt/nsd

服务端:

[[email protected] /]# vim /etc/exports

/abc ? 172.25.0.0/24(rw,no_root_squash) ? ?#不压榨客户端root权限

[[email protected] /]# systemctl restart nfs-server

客户端:

[[email protected] /]# systemctl ?restart nfs ?#重起客户端服务

[[email protected] /]# touch /mnt/nsd/5.txt

二、普通用户

??

? ? ?客户端普通用户访问服务端nfs-server服务,

? ? ?服务端会以客户端相同UID身份的本地用户进行权限判定

? ? LDAP : ?网络用户,提供用户名

? ? kerberos : 密码验证,实现“一次密码认证,多次免密登录”的通行证机制

服务端:

[[email protected] /]# lab ?nfskrb5 ?setup

[[email protected] /]# grep ldapuser0 /etc/passwd

[[email protected] /]# id ldapuser0

1.部署kerberos加密的密钥文件

wget http://172.25.254.254/pub/keytabs/server0.keytab -O /etc/krb5.keytab

[[email protected] /]# ls /etc/krb5.keytab?

2.修改配置文件

[[email protected] /]# vim /etc/exports

?/abc ? 172.25.0.0/24(rw,no_root_squash,sec=krb5p)------{sec=krb5p}表示共享密码的验证去找kerberos

3.重起nfs-server与nfs-secure-server

# systemctl restart nfs-server ?nfs-secure-server

客户端:

[[email protected] /]# lab ?nfskrb5 ?setup

[[email protected] /]# grep ldapuser0 /etc/passwd

[[email protected] /]# id ldapuser0

1.部署kerberos加密的密钥文件

wget http://172.25.254.254/pub/keytabs/desktop0.keytab -O /etc/krb5.keytab

[[email protected] /]# ls /etc/krb5.keytab?

2.修改/etc/fstab

172.25.0.11:/abc /mnt/nsd ?nfs ?_netdev,sec=krb5p 0 0

3.重起nfs与nfs-secure服务

[[email protected] /]# systemctl restart nfs ?nfs-secure

4.验证挂载

[[email protected] /]# umount /mnt/nsd

? ? ? ? ?

?

原文:http://blog.51cto.com/13513556/2048525

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值