练习题9-13

来源:互联网 发布:淘宝 店铺券和专享券 编辑:程序博客网 时间:2024/06/14 06:51

        <<第九单元练习>>
1.
desktop主机中建立用户westos,并设定其密码为westoslinux

[root@localhost Desktop]#useradd westos

[root@localhost Desktop]#echo "westoslinux" | passwd --stdin westos
2.
配置desktop中的sshd服务要求如下:
*
)设定sshd服务只允许westos用户可以被访问使用

[root@localhost Desktop]#vim /etc/ssh/sshd_config

更改配置文件 : PermitRootLogin no    //不允许超级用户登录 
                AllowUsers westos     //建立用户白名单

*)创建westos用户的key认证方式

[root@localhost Desktop]#ssh-keygen

[root@localhost Desktop]#ssh-copy-id-i /root/.ssh/id_rsa.pub westos@172.25254.118
*
)设定westos用户只允许使用key认证方式,屏蔽其系统密码认证方式

[root@localhost Desktop]#vim /etc/ssh/sshd_config

更改配置文件:PasswordAuthentication no    //取消密码认证


[root@localhost Desktop]#systemctl restart sshd

        <<第十单元练习题>>
1.
配置desktop主机和server主机的日志服务要求如下:
*
desktop主机中的日志全部定向到/var/log/westos文件中

[root@localhost Desktop]#vim /etc/rsyslog.conf

写入:*.*                                    /var/log/westos

[Esc]

:wq
*
)时时同步desktop主机中的所有日志到server
[root@localhost Desktop]#vim /etc/rsyslog.conf

写入:*.*                                   @172.25.254.118

[Esc]

:wq
2.
server主机中用timedatectl命令设定系统时区为上海,时间为111111

[root@localhost Desktop]#timedatectl set-timezone Asia/Shanghai

[root@localhost Desktop]#timedatectl set-time "11:11:11"
3.
配置server主机的chronyd服务,使server主机中的时间可以被desktop主机同步

[root@localhost Desktop]#vim /etc/chrony.conf

更改 :  allow 172.25.254.118/24           //允许172.25.254.118同步时间

        local stratum 10                   //不去同步任何人时间
4.
同步server主机中的时间到desktop主机中

[root@localhost Desktop]#vim /etc/chrony.conf

更改配置文件:删除3,4,5,6行;

server  172.25.254.218 iburst

[Esc]

:wq

systemctl restart chrony

[root@localhost Desktop]#chronyc sources -v


5.
配置系统中的systemd-journal程序,使journal命令可以查看到关机前的日志
[root@localhost Desktop]#mkdir /var/log/journal
[root@localhost Desktop]#chown root:systemd-journal /var/log/journal
[root@localhost Desktop]#chmod 2755 /var/log/journal
[root@localhost Desktop]#killall -1 systemd-journald
[root@localhost Desktop]#ls /var/log/journal/

     <<第十一单元练习>>
1.
在系统中创建set-ip-tool命令要求如下
当在系统中执行set-ip-tool 172.25.254.X
*)
会自动显示ifconfig命令的输出
*)
系统ip被设定为:172.25.254.X
*)
系统网关被设定为:172.25.254.250
*)
系统dns被设定为:172.25.254.250

[root@localhost Desktop]#vim /mnt/set-ip-tool.sh

文档内输入:

#!/bin/bash

cat > /etc/sysconfig/network-scripts/ifcfg-eth0 <<end

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=none

IPADDR=$1

NETMASK=255.255.255.0

GATEWAY=172.25.254.250

DNS1=172.25.254.250

end


systemctl restart network

[Esc]

:wq

[root@localhost Desktop]#chmod +x /mnt/set-ip-tool.sh

       <<第十二单元练习>>
1.
server主机中把/etc目录打包压缩到/mnt中,名字为etc.tar.gz

[root@localhost Desktop]#tar zcf /mnt/etc.tar.gz /etc
2.
复制server主机中的etc.tar.gzdesktop主机的/mnt

[root@localhost Desktop]#scp /mnt/etc.tar.gz root@172.25.254.118:/mnt
3.
同步server主机中的/etc中的所有文件到desktop主机中/mnt中,包含链接文件
 [root@localhost Desktop]#rsync -l /etc/ root@172.25.254.118:/mnt

     <<第十三单元练习>>
1.
server主机中配置yum仓库,并安装gcc编辑器

[root@localhost Desktop]#mount /rhel-server-7.1-x86_64-dvd.iso /mnt

[root@localhost Desktop]#vim /etc/yum.repos.d/yum.repo

输入:   [Server]

          name=chen

          baseurl=file:///mnt

          gpgcheck=0

[Esc]

:wq

[root@localhost Desktop]#yum clean all

[root@localhost Desktop]#yum install gcc -y



 
0 0