ntp时间服务器和远程登录服务SSH

目录

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

分析:首先客户端和服务主机同步,我们可以让客户端主机根据服务器主机进行同步,服务器主机从阿里云来进行同步

一,服务器主机从阿里云同步时间

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

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

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

​编辑

五,查看客户端是否同步

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

分析:首先是使用客户端redhat用户去基于公钥验证进行连接,首先我们先增加个用户,因为是客户端去的redhat用户访问服务器端,所以我们需要在客户端redhat用户创建密钥然后发给客户端

一,创建新用户redhat

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

三,客户端测试


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

分析:首先客户端和服务主机同步,我们可以让客户端主机根据服务器主机进行同步,服务器主机从阿里云来进行同步

一,服务器主机从阿里云同步时间

[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    17     9  +8156ns[ +654us] +/-   24ms
[root@server ~]# timedatectl status 
               Local time: 六 2023-03-18 19:32:49 CST
           Universal time: 六 2023-03-18 11:32:49 UTC
                 RTC time: 六 2023-03-18 11:32:49
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[root@server ~]# date 
2023年 03月 18日 星期六 19:32:51 CST

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

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

[root@server ~]# systemctl restart chronyd

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

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

[root@server ~]# systemctl restart chronyd

五,查看客户端是否同步

[root@node1 ~]# systemctl restart chronyd
[root@node1 ~]# 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.38.128                3   6     3     1  -9426us[-9426us] +/-   26ms
[root@node1 ~]# timedatectl status 
               Local time: 六 2023-03-18 19:40:03 CST
           Universal time: 六 2023-03-18 11:40:03 UTC
                 RTC time: 六 2023-03-18 11:40:03
                Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
[root@node1 ~]# date 
2023年 03月 18日 星期六 19:40:09 CST


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

分析:首先是使用客户端redhat用户去基于公钥验证进行连接,首先我们先增加个用户,因为是客户端去的redhat用户访问服务器端,所以我们需要在客户端redhat用户创建密钥然后发给客户端

一,创建新用户redhat

[root@node1 ~]# useradd redhat        
[root@node1 ~]# passwd redhat 
更改用户 redhat 的密码 。
新的密码: 
重新输入新的密码: 
passwd:所有的身份验证令牌已经成功更新。

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

[redhat@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]-----+
[redhat@node1 root]$ 
[redhat@node1 root]$ ssh-copy-id root@192.168.38.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.

三,客户端测试

[redhat@node1 root]$ ssh root@192.168.38.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 ~]# 
[root@server ~]# 
[root@server ~]# 

此时便切换完成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将CentOS服务器时间修改为以前的时间,可以按照以下步骤进行操作: 1. 首先,登录到CentOS服务器的终端或远程登录工具(如SSH)。 2. 使用root用户或具有管理员权限的用户进行下一步操作。 3. 检查当前的系统时间。可以使用以下命令来获取当前时间: ``` date ``` 4. 停止并禁用NTP服务NTP(Network Time Protocol)是一种用于同步计算机时间的协议。在修改时间之前,必须停止这个服务。可以使用以下命令来停止和禁用NTP服务: ``` systemctl stop ntpd.service systemctl disable ntpd.service ``` 5. 使用以下命令来修改当前系统时间为以前的时间(请将`YYYY-MM-DD HH:MM:SS`替换为具体的日期和时间): ``` date -s "YYYY-MM-DD HH:MM:SS" ``` 6. 检查修改后的系统时间是否正确。可以再次使用以下命令来获取当前时间: ``` date ``` 7. 如果系统时间没有更新,可能是因为硬件时钟(BIOS时钟)和系统时间不一致。可以使用以下命令来将硬件时钟设置为当前系统时间(需要root权限): ``` hwclock -w ``` 8. 重新启动NTP服务。可以使用以下命令来启动和设置NTP服务为开机自启动: ``` systemctl start ntpd.service systemctl enable ntpd.service ``` 9. 最后,再次检查系统时间是否正确。 请注意,修改服务器时间可能会对系统和应用程序造成影响,特别是如果时间被修改为过去的时间。在修改时间之前,请确保了解所有相关的潜在影响,并根据需要备份重要的数据和配置文件。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值