RHCE 模拟题及答案

Linux大全评论384 views阅读模式

RHCE部分

一、 开启SELinux
 SELinux必须是Enforcing状态
[root@ www.linuxidc.com ~]# setup

二、 搭建NFS服务
[root@ www.linuxidc.com ~]# yum -y install nfs-utils
 共享出/data目录
 允许172.16.0.0/16读写方式访问
[root@ www.linuxidc.com ~]# vi /etc/exports
/data     172.16.0.0/16(rw,async)
[root@ www.linuxidc.com ~]# chkconfig nfs on
[root@ www.linuxidc.com ~]# service nfs start

三、 搭建FTP服务
 匿名用户可以访问ftp
 student1和student2登录ftp后,只能在自己的家目录下
 student3不能登录ftp
 允许从example.com这个域来访问
 不允许从cracker.org来访问
[root@ www.linuxidc.com ~]# yum -y install vsftpd
[root@ www.linuxidc.com ~]# vim /etc/vsftpd/vsftpd.conf
 chroot_list_enable=YES
 chroot_list_file=/etc/vsftpd/chroot_list
[root@ www.linuxidc.com ~]# echo 'student1' > /etc/vsftpd/chroot_list
[root@ www.linuxidc.com ~]# echo 'student2' >> /etc/vsftpd/chroot_list
[root@ www.linuxidc.com ~]# echo 'student3' >> /etc/vsftpd/ftpusers
[root@ www.linuxidc.com ~]# getsebool -a | grep ftp
ftp_home_dir --> off
[root@ www.linuxidc.com ~]# setsebool -P ftp_home_dir on
[root@ www.linuxidc.com ~]# vim /etc/hosts. deny
 vsftpd:ALL
[root@ www.linuxidc.com ~]# echo 'vsftpd:172.16.0.0/255.255.0.0' >> /etc/hosts.allow
[root@ www.linuxidc.com ~]# whereis vsftpd
 vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz
[root@ www.linuxidc.com ~]# ldd /usr/sbin/vsftpd | grep libwrap.so
        libwrap.so.0 => /lib/libwrap.so.0 (0x00170000)

测试:分别用student1 student2 student3 student4 登录ftp并查看当前路径

四、 配置samba服务?
 共享出/yangbang目录
 只有172.16.0.0/16和192.168.1.0/24和127.0.0.1可以访问
 共享出的名字是[sharefile],默认可以查看到该共享
 只有student组才有写的权限
 student组成员的家目录也要被共享
 设置Netbios name=GUESTX
[root@ www.linuxidc.com ~]# yum -y install samba
[root@ www.linuxidc.com ~]# vim /etc/samba/smb.conf
  ;       passdb backend = tdbsam  //注释掉这行
  netbios name = GUEST2002   //去掉注释并改名
        [sharefile]
        comment = share file
        path = /yangbang
        browseable = no
        write list = @student
        hosts allow = 172.16.0.0/16 192.168.1.0/24 127.0.0.1
 [root@ www.linuxidc.com ~]# service smb restart
[root@ www.linuxidc.com ~]# chkconfig smb on
[root@ www.linuxidc.com ~]# getsebool -a | grep samba
   samba_enable_home_dirs --> off
[root@ www.linuxidc.com ~]# setsebool -P samba_enable_home_dirs on
[root@ www.linuxidc.com ~]# chgrp student /yangbang/
[root@ www.linuxidc.com ~]# chmod g+w /yangbang/
[root@ www.linuxidc.com ~]# chcon -R -t samba_share_t /yangbang/
[root@ www.linuxidc.com ~]# testparm   //测试samba的配置文件
[root@ www.linuxidc.com ~]# smbclient //192.168.142.200/sharefile -U student       
  Password:
  Domain=[GUEST2002] OS=[Unix] Server=[Samba 3.0.33-3.14.el5]
smb: \> pwd
   Current directory is \\192.168.142.200\sharefile\

五、 搭建ssh服务
 puser用户不能远程登录
 不允许cracker.org这个域的访问
[root@ www.linuxidc.com certs]# whereis sshd
 sshd: /usr/sbin/sshd /usr/share/man/man8/sshd.8.gz
[root@ www.linuxidc.com certs]# ldd /usr/sbin/sshd | grep libwrap.so
    libwrap.so.0 => /lib/libwrap.so.0 (0x0096b000)
[root@ www.linuxidc.com certs]# vim /etc/hosts.deny
 sshd,vsftpd:ALL
[root@ www.linuxidc.com certs]# vim /etc/hosts.allow
 sshd:192.168.142.0/255.255.255.0 192.168.0.0/255.255.255.0
[root@ www.linuxidc.com certs]# vim /etc/ssh/sshd_config
 //增加以下行
  DenyUsers puser
[root@masternis pub]# service sshd restart

企鹅博客
  • 本文由 发表于 2019年9月15日 04:39:33
  • 转载请务必保留本文链接:https://www.qieseo.com/211365.html

发表评论