1.指定在每天凌晨4:00将该时间点之前的系统日志信息(/var/log/messages )备份到目录下/backup,备份后日志文件名显示格式logfileYY-MM-DD-HH-MM
[root@ssh-client ~]# mkdir /backup
[root@ssh-client ~]# vim /etc/crontab
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 6 * * * root /bin/cp /var/log/messages /backup/logfile date+\%Y-\%m-\%d\%H:\%M:\%S
2.配置ssh免密登陆:客户端主机通过redhat用户基于秘钥验证方式进行远程连接服务器的root用户
客户端:
创密钥:
[root@ssh-client ~]# ssh -keygen
传密钥给服务器root用户:
[root@ssh-client ~]# ssh-copy-id root@192.168.154.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.154.128 (192.168.154.128)' can't be established.
ED25519 key fingerprint is SHA256:8gUs5oYIzYW3HpBvicfP4mqW1OIwa8AWgZi69aCkQtA.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.154.128's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.154.128'"
and check to make sure that only the key(s) you wanted were added.
远程连接服务器root用户:
[redhat@localhost root]$ ssh 'root@192.168.130.128'
Activate the web console with: systemctl enable --now cockpit.socket
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last failed login: Tue Mar 14 20:59:14 CST 2023 from 192.168.130.129 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Tue Mar 14 20:51:16 2023 from 192.168.146.1
[root@ssh-client ~]#
3.搭建一个web网站,网站显示hello world内容