ntp时间服务器和ssh免密登录

1.配置ntp时间服务器,确保客户端主机能和服务主机同步时间
一,服务器主机从阿里云同步时间

[root@server ~]# vim /etc/chrony.conf

方法一:是指时间同步服务器的地址,可以改为阿里时间服务器

 方法二:删除所有内容,复制阿里开源镜像站的推荐配置 

 二,重启服务,查看服务器主机是否同步

[root@server ~]# vim /etc/chrony.conf
[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     3     2  -5684us[-5684us] +/-   26ms
[root@server ~]# timedatectl status
               Local time: 二 2023-03-21 20:58:25 CST
           Universal time: 二 2023-03-21 12:58:25 UTC
                 RTC time: 二 2023-03-21 12:58:25
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[root@server ~]# date
2023年 03月 21日 星期二 20:58:38 CST

三,配置允许访问的ip,并重启服务

[root@server ~]# vim /etc/chrony.conf
[root@server ~]# systemctl restart chronyd

 

 

 四,对于客户端修改主配置文件中时间服务器地址,并重启服务

[root@node ~]# vim /etc/chrony.conf
[root@node ~]# systemctl restart chronyd

 五,查看客户端是否同步

[root@node ~]# systemctl restart chronyd
[root@node ~]# 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               
===============================================================================
^* 192.168.111.128               3   6    17    18    -30us[ +108us] +/-   24ms
[root@node ~]# timedatectl status
               Local time: 二 2023-03-21 23:11:09 CST
           Universal time: 二 2023-03-21 15:11:09 UTC
                 RTC time: 二 2023-03-21 15:11:09
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[root@node ~]# date
2023年 03月 21日 星期二 23:11:14 CST

2.配置ssh免密登陆,能够通过客户端主机通过redhat用户和服务端主机基于公钥验证方式进行远程连接

 一,创建新用户t1

[root@node1 ~]# useradd t1
[root@npde1 ~]# passwd t1
更改用户 t1 的密码 。
新的密码: 
无效的密码: 密码少于 8 个字符
重新输入新的密码: 
passwd:所有的身份验证令牌已经成功更新。

二,创建新的密钥对,并且发送到指定目录

 
[t1@node1 root]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/redhat/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/redhat/.ssh/id_rsa
Your public key has been saved in /home/redhat/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:peN3IXp4nusrQ5Ca/umHNzX6fO6SPJSSf6LCnv2mNc8 redhat@node1
The key's randomart image is:
+---[RSA 3072]----+
|                 |
|                 |
|       .  .      |
|      o  o       |
|     o .S....    |
|    o  .++=. .   |
|   . . o+B*o.    |
|    . ++BBO*o    |
|     +*++@X@E    |
+----[SHA256]-----+
[t1@node1 root]$ 
[t1@node1 root]$ ssh-copy-id root@192.168.111.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/redhat/.ssh/id_rsa.pub"
/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.38.128's password: 
 
Number of key(s) added: 1
 
Now try logging into the machine, with:   "ssh 'root@192.168.38.128'"
and check to make sure that only the key(s) you wanted were added.

三,客户端测试

 
[t1@node1 root]$ ssh root@192.168.111.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 login: Sat Mar 18 19:58:18 2023 from 192.168.38.136
[root@server ~]# 

切换完成

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值