1.配置ntp时间服务器,确保客户端主机能和服务主机同步时间
[root@localhost ~]# hostname server #修改服务器主机名
[root@localhost ~]# bash
[root@server ~]# vim /etc/chrony.conf #配置服务器主机
allow 192.168.0.0/16
local stratum 10[root@server ~]# systemctl restart chronyd #服务器主机重启chronyd
[root@server ~]# date #查看此时服务器主机时间
Sat Aug 27 18:47:14 CST 2022[root@localhost ~]# date #查看此时客户端主机时间
Sat Aug 27 18:28:32 CST 2022
[root@localhost ~]# # vim /etc/chrony.conf #配置客户端主机使其同步到服务器主机
pool 192.168.101.134 iburst
[root@localhost ~]# # systemctl restart chronyd #重启客户端主机chronyd
[root@localhost ~]# # date #查看此时客户端主机时间
Thu Dec 1 12:01:40 CST 2022
[root@localhost ~]# # date
Sat Aug 27 18:49:43 CST 2022
[root@localhost ~]#
2.配置ssh免密登陆,能够通过客户端主机通过redhat用户和服务端主机基于公钥验证方式进行远程连接
#制作秘钥对
root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Z9/0qRdVkDDH8KmIeBBMhDIckSc7XpFD2CYLbhN5PIE root@localhost
The key's randomart image is:
+---[RSA 3072]----+
| .*Oo*+ ++oo |
|.EO+O .. +o..|
|..oX.o. o .|
| ++ . o . . . .|
|...o . S + . . .|
| . . o . o o.|
| . ..o|
| .. |
| .. |
+----[SHA256]-----+
#发送秘钥到服务端主机redhat用户的/root/.ssh/id_rsa.pub目录下
[root@localhost ~]# ssh-copy-id -i redhat@192.168.101.134
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.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
redhat@192.168.101.134's password:Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'redhat@192.168.101.134'"
and check to make sure that only the key(s) you wanted were added.
#在客户端远程登录服务端的radhat用户
[root@localhost ~]# ssh redhat@192.168.101.134
Activate the web console with: systemctl enable --now cockpit.socketThis system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --registerLast login: Sat Aug 27 19:32:09 2022 from 192.168.101.1
[redhat@server ~]$