服务器配置
[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 重启软件以加载配置
客户端配置
[root@localhost ~]# vim /etc/chrony.conf
修改如下内容
pool 192.168.171.140 iburst 从该服务器处同步时间
[root@localhost ~]# systemctl restart chronyd 重启chronyd 服务
测试
当前时间
[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免密登陆,能够客户端主机通过普通用户和服务端主机基于公钥验证方式进行远程连接
客户端生成密钥
[root@server ~]# ssh-keygen
[shan@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
[shan@server .ssh]$ ll
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
将 id_rsa.pub 文件追加到授权的authorized_keys
[root@server .ssh]# cat id_rsa.pub >> authorized_keys
[shan@server .ssh]$ cat id_rsa.pub >> authorized_keys
注:非管理员用户需要特别修改文件权限
[shan@server .ssh]$ chmod u=rw,go-rwx authorized_keys
拥有者可读写,其他人不可读写执行权限 也可做chmod 600 FILE
重启服务登录本地做测试
systemctl restart sshd 重启服务ssh
将公钥传送到需要登录的远程服务器[root@server ~]# ssh-copy-id 192.168.171.139
[shan@server ~]# ssh-copy-id 192.168.171.139