Linux定时计划&chrony时钟同步服务练习、对称&非对称加密区别

目录

1.at 配置在5小时后,将 "This is a at task" 写入 root家目录中的at_test文件中

2.crontab配置,每周六,周日 9点半,14点 提醒我上RHCE课 写入root家目录中的cron_test文件中

3.在两台Linux上部署chrony服务:要求:第一台从阿里云服务器同步时间, 第二台从第一台同步时间

4.什么是对称加密,什么是非对称加密,对称加密都有哪些加密算法,非对称加密都要哪些加密算法

1)对称加密

2)非对称加密


1.at 配置在5小时后,将 "This is a at task" 写入 root家目录中的at_test文件中

[root@server ~]# at now +5 hours
warning: commands will be executed using /bin/sh
at> echo "This is a at task" > /root/at_test
at> <EOT>
job 5 at Sun Jul 24 02:12:00 2022
[root@server ~]# atq
5	Sun Jul 24 02:12:00 2022 a root

2.crontab配置,每周六,周日 9点半,14点 提醒我上RHCE课 写入root家目录中的cron_test文件中

[root@server ~]# crontab -e                # 编辑crontab
30 9 * * 6,7 echo "It's time for RHCE lessons!" > /root/cron_test
0 14 * * 6,7 echo "It's time for RHCE lessons!" > /root/cron_test
~
~
[root@server ~]# crontab -l                    # 查看
30 9 * * 6,7 echo "It's time for RHCE lessons!" > /root/cron_test
0 14 * * 6,7 echo "It's time for RHCE lessons!" > /root/cron_test

3.在两台Linux上部署chrony服务:要求:第一台从阿里云服务器同步时间, 第二台从第一台同步时间

1)第一台:

a.确保开启chronyd服务

[root@server ~]# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor >
   Active: active (running) since Sat 2022-07-23 21:07:58 CST; 21min ago
   ……

b.修改chrony的配置文件/etc/chrony.conf

[root@server ~]# vim /etc/chrony.conf 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.centos.pool.ntp.org iburst
server ntp.aliyun.com iburst        # 设置阿里云网络时间服务地址

……

# Allow NTP client access from local network.    
allow 192.168.5.0/24                # 设置第二台Linux的ip地址或包含该地址的网段
# Serve time even if not synchronized to a time source.
local stratum 10

c.重启chonyd服务,检查有效

[root@server ~]# systemctl restart chronyd
[root@server ~]# chronyc sources -v

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 203.107.6.88                  2   6   177    26   -274us[ -934us] +/-   20ms

d.查看时间同步状态

[root@server ~]# timedatectl status 
               Local time: Sat 2022-07-23 21:55:04 CST
           Universal time: Sat 2022-07-23 13:55:04 UTC
                 RTC time: Sat 2022-07-23 13:57:01
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

e.开启网络时间同步

[root@server ~]# timedatectl set-ntp true

f.第一台Linux时间同步完成

[root@server ~]# timedatectl status 
               Local time: Sat 2022-07-23 21:58:46 CST
           Universal time: Sat 2022-07-23 13:58:46 UTC
                 RTC time: Sat 2022-07-23 13:58:47
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

2)第二台:

a.确保开启chronyd服务

[root@client ~]# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor >
   Active: active (running) since Sat 2022-07-23 22:09:48 CST; 29s ago

b.修改chrony的配置文件/etc/chrony.conf

[root@client ~]# vim /etc/chrony.conf 
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.rhel.pool.ntp.org iburst
server 192.168.5.128 iburst                    # 只需配置第一台Linux的ip地址
……

c.重启chonyd服务,检查有效

[root@client ~]# systemctl restart chronyd
[root@client ~]# chronyc sources -v
210 Number of sources = 1

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 192.168.5.128                 3   6    17     6   -149us[ -216us] +/-   24ms

d.查看时间同步状态

[root@client ~]# timedatectl status 
               Local time: Sat 2022-07-23 22:15:22 CST
           Universal time: Sat 2022-07-23 14:15:22 UTC
                 RTC time: Sat 2022-07-23 14:17:26
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no
              NTP service: active
          RTC in local TZ: no

e.开启网络时间同步

[root@client ~]# timedatectl set-ntp true

f.第二台Linux时间同步完成

[root@client ~]# timedatectl status 
               Local time: Sat 2022-07-23 22:19:41 CST
           Universal time: Sat 2022-07-23 14:19:41 UTC
                 RTC time: Sat 2022-07-23 14:19:41
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

4.什么是对称加密,什么是非对称加密,对称加密都有哪些加密算法,非对称加密都要哪些加密算法

1)对称加密

采用单钥密码系统的加密方法,同一个密钥可以同时用作信息的加密和解密,这种加密方法称为对称加密,也称为单密钥加密。

在对称加密算法中常用的算法有:DES3DESTDEABlowfishRC2RC4RC5IDEASKIPJACK等。

2)非对称加密

对称加密算法加密和解密时使用的是同一个秘钥;而非对称加密算法需要两个密钥来进行加密和解密,这两个密钥是公开密钥(public key,简称公钥)和私有密钥(private key,简称私钥)。

在对称加密算法中常用的算法有:RSA、DSA、ECDSA等。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

俗人不俗鸭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值