> 文章列表 > HCLE--虚拟机安装ntp等相关服务出现报错解决和通过SSH实现免密登录

HCLE--虚拟机安装ntp等相关服务出现报错解决和通过SSH实现免密登录

HCLE--虚拟机安装ntp等相关服务出现报错解决和通过SSH实现免密登录

.1 在服务端主机上安装ntp服务:

yum install ntp

1.2 修改/etc/ntp.conf文件,将默认的ntp服务器地址替换为可用的ntp服务器地址。例如:

server ntp1.aliyun.com iburst server ntp2.aliyun.com iburst server ntp3.aliyun.com iburst

1.3 启动ntp服务并将其设置为开机自启动:

systemctl start ntpd systemctl enable ntpd

1.4 在客户端主机上安装ntp服务,并将其配置为同步服务端主机的时间:

yum install ntp ntpdate [服务端IP地址]

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

检查 更新后找不到ntp包 于是掉头检查了yum源 没有问题 

问了gtp发现二者存一即可

2.1 在客户端主机上使用ssh-keygen命令生成密钥:

ssh-keygen -t rsa
[root@localhost ~]# ssh-keygen
Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'.
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:irRO8IKD7MTtVa4b1xAAzaQTZ/woxYHq+I6KNBYS01o root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|   oO*.          |
| . .=*.          |
|o Eo. o.         |
| * ... ..        |
|=.. o  oS        |
|*oo+ oo.o        |
|+O..=o.o .       |
|*o++. +          |
|=o...o.          |
+----[SHA256]-----+

 发现防火墙问题 检查防火墙        

2.2 将生成的公钥(默认为~/.ssh/id_rsa.pub)复制到服务端主机上的~/.ssh/authorized_keys文件中:上传秘钥

 

成功


2.3 修改服务端主机的ssh配置文件/etc/ssh/sshd_config,确保以下选项被启用:

PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys

2.4 重启ssh服务:

systemctl restart sshd

​​​​​​​测试

[redhat@client .ssh]$ ssh 192.168.227.128
The authenticity of host '192.168.227.128 (192.168.227.128)' can't be established.
ED25519 key fingerprint is SHA256:IjiKi+oexrRWTbUACwNqXYQvu2F8yakPx49b7PW9lto.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.227128' (ED25519) to the list of known hosts.
redhat@192.168.227.128's password: 
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 Apr  18 11:10:12 2023
[redhat@server ~]$ 

足球知识