当前位置:   article > 正文

ntp和ssh命令_finalshell命令./ntpc

finalshell命令./ntpc

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

1.关闭防火墙、selinux:

  1. [root@server ~]# systemctl stop firewalld
  2. [root@server ~]# setenforce 0
  3. [root@server ~]# getenforce
  4. Permissive

2.服务器主机从阿里云同步时间

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

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

  1. [root@server ~]# systemctl restart chronyd
  2. [root@server ~]# chronyc sources -v
  3. .-- Source mode '^' = server, '=' = peer, '#' = local clock.
  4. / .- Source state '*' = current best, '+' = combined, '-' = not combined,
  5. | / 'x' = may be in error, '~' = too variable, '?' = unusable.
  6. || .- xxxx [ yyyy ] +/- zzzz
  7. || Reachability register (octal) -. | xxxx = adjusted offset,
  8. || Log2(Polling interval) --. | | yyyy = measured offset,
  9. || \ | | zzzz = estimated error.
  10. || | | \
  11. MS Name/IP address Stratum Poll Reach LastRx Last sample
  12. ===============================================================================
  13. ^* 203.107.6.88 2 6 17 9 +8156ns[ +654us] +/- 24ms
  14. [root@server ~]# timedatectl status
  15. Local time: 六 2023-03-18 19:32:49 CST
  16. Universal time: 六 2023-03-18 11:32:49 UTC
  17. RTC time: 六 2023-03-18 11:32:49
  18. Time zone: Asia/Shanghai (CST, +0800)
  19. System clock synchronized: yes
  20. NTP service: active
  21. RTC in local TZ: no
  22. [root@server ~]# date
  23. 20230318日 星期六 19:32:51 CST

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

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

[root@server ~]# systemctl restart chronyd

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

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

[root@server ~]# systemctl restart chronyd

 6.查看客户端是否同步

  1. [root@node1 ~]# systemctl restart chronyd
  2. [root@node1 ~]# chronyc sources -v
  3. .-- Source mode '^' = server, '=' = peer, '#' = local clock.
  4. / .- Source state '*' = current best, '+' = combined, '-' = not combined,
  5. | / 'x' = may be in error, '~' = too variable, '?' = unusable.
  6. || .- xxxx [ yyyy ] +/- zzzz
  7. || Reachability register (octal) -. | xxxx = adjusted offset,
  8. || Log2(Polling interval) --. | | yyyy = measured offset,
  9. || \ | | zzzz = estimated error.
  10. || | | \
  11. MS Name/IP address Stratum Poll Reach LastRx Last sample
  12. ===============================================================================
  13. ^? 192.168.38.128 3 6 3 1 -9426us[-9426us] +/- 26ms
  14. [root@node1 ~]# timedatectl status
  15. Local time: 六 2023-03-18 19:40:03 CST
  16. Universal time: 六 2023-03-18 11:40:03 UTC
  17. RTC time: 六 2023-03-18 11:40:03
  18. Time zone: Asia/Shanghai (CST, +0800)
  19. System clock synchronized: yes
  20. NTP service: active
  21. RTC in local TZ: no
  22. [root@node1 ~]# date
  23. 20230318日 星期六 19:40:09 CST

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

1.创建新用户redhat

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

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

  1. [redhat@node1 root]$ ssh-keygen -t rsa
  2. Generating public/private rsa key pair.
  3. Enter file in which to save the key (/home/redhat/.ssh/id_rsa):
  4. Enter passphrase (empty for no passphrase):
  5. Enter same passphrase again:
  6. Your identification has been saved in /home/redhat/.ssh/id_rsa
  7. Your public key has been saved in /home/redhat/.ssh/id_rsa.pub
  8. The key fingerprint is:
  9. SHA256:peN3IXp4nusrQ5Ca/umHNzX6fO6SPJSSf6LCnv2mNc8 redhat@node1
  10. The key's randomart image is:
  11. +---[RSA 3072]----+
  12. | |
  13. | |
  14. | . . |
  15. | o o |
  16. | o .S.... |
  17. | o .++=. . |
  18. | . . o+B*o. |
  19. | . ++BBO*o |
  20. | +*++@X@E |
  21. +----[SHA256]-----+
  22. [redhat@node1 root]$
  23. [redhat@node1 root]$ ssh-copy-id root@192.168.38.128
  24. /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/redhat/.ssh/id_rsa.pub"
  25. /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
  26. /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
  27. root@192.168.38.128's password:
  28. Number of key(s) added: 1
  29. Now try logging into the machine, with: "ssh 'root@192.168.38.128'"
  30. and check to make sure that only the key(s) you wanted were added.

3.客户端测试

  1. [redhat@node1 root]$ ssh root@192.168.38.128
  2. Activate the web console with: systemctl enable --now cockpit.socket
  3. Register this system with Red Hat Insights: insights-client --register
  4. Create an account or view all your systems at https://red.ht/insights-dashboard
  5. Last login: Sat Mar 18 19:58:18 2023 from 192.168.38.136
  6. [root@server ~]#
  7. [root@server ~]#
  8. [root@server ~]#

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/155696
推荐阅读
相关标签
  

闽ICP备14008679号