使用2台Redhat 虚拟机
服务器端 IP192.168.171.120 主机名 [root@Server~]
客户端 IP 192.168.171.121 主机名 [root@localhost ~]
前置操作首先保证时区一致
[root@server ~]# timedatectl 使用该命令查看 保证时区和ntp service 都是active状态
systemctl stop firewalld 防火墙关闭
setenforce 0 关闭selinux
[root@localhost ~]# rpm -qa | grep chron 检查有没有安装 redhat 虚拟机 ntp服务软件为 chron
2服务器配置
[root@server~]# vim /etc/chrony.conf 对其配置文件进行编辑
修改如下内容
#pool
1 使用2台Redhat 8.5 虚拟机
服务器端 IP192.168.171.140 主机名 [root@Server~]
客户端 IP 192.168.171.135 主机名 [root@localhost ~]
前置操作首先保证时区一致
[root@server ~]# timedatectl 使用该命令查看 保证时区和ntp service 都是active状态
systemctl stop firewalld 防火墙关闭
setenforce 0 关闭selinux
[root@localhost ~]# rpm -qa | grep chron 检查有没有安装 redhat 8.5 ntp服务软件为 chron
2服务器配置
[root@server~]# vim /etc/chrony.conf 对其配置文件进行编辑
修改如下内容
#pool 2.rhel.pool.ntp.org iburst 服务器端不需要向上层同步时间
allow 192.168.171.0/24 允许客户端向本服务器同步时间
local stratum 10 定义本地主机时间服务器在第10层级 15以内保证偏差在1-50ms
[root@server ~]# systemctl restart chronyd 重启软件以加载配置
3客户端配置
[root@localhost ~]# vim /etc/chrony.conf
修改如下内容
pool 192.168.171.140 iburst 从该服务器处同步时间
[root@localhost ~]# systemctl restart chronyd 重启chronyd 服务
4测试
[root@sever ~]# date
Sat Aug 27 19:22:49 CST 2022
[root@localhost ~]# date
Sat Aug 27 19:22:56 CST 2022 保持一致
服务器修改时间 检查客户机
[root@sever ~]# date 111110102022.20
Fri Nov 11 10:10:20 CST 2022
[root@sever ~]# systemctl restart chronyd
[root@localhost ~]# date
Fri Nov 11 10:10:20 CST 2022
二、配置ssh免密登陆,能够客户端主机通过普通用户和服务端主机基于公钥验证方式进行远程连接
客户机和服务端设备系统为redhat8.5 客户端IP为192.168.171.140
服务端IP 192.168.171.139
以下演示root管理员
使用命令
rpm -qa | grep openssh
rpm -qa | grep rsync
客户端生成密钥
[root@server ~]# ssh-keygen
查看root权限下有没有.ssh文件
Redhat用户该文件在/home/user下
[root@server .ssh]# ll
-rw-------. 1 root root 2610 Aug 28 07:06 id_rsa
-rw-r--r--. 1 root root 580 Aug 28 07:06 id_rsa.pub
total 8
-rw-------. 1 shan shan 2602 Aug 28 07:26 id_rsa
-rw-r--r--. 1 shan shan 565 Aug 28 07:26 id_rsa.pub
[root@server .ssh]# cat id_rsa.pub >> authorized_keys
[shan@server .ssh]$ cat id_rsa.pub >> authorized_keys
重启做本地测试登录
systemctl restart sshd 重启服务ssh
将公钥传输到需要登陆的远程服务器中
[root@server ~]# ssh-copy-id 192.168.171.139
[shan@server ~]# ssh-copy-id 192.168.171.139