大网数据广告活动
服务器运维问答

What does "No matching private key for certificate" mean for openssh certificate-signed host keys?

· 52CE 我爱测

I'm trying to set up OpenSSH host certificates to cut down on the effort of managing ssh_known_hosts as hosts come and go at my site. I created a SSH key pair to serve as the CA key. I then set up Ansible to sign a host key with …

问题原文

原帖链接 · edgewood · CC BY-SA 4.0

I'm trying to set up OpenSSH host certificates to cut down on the effort of managing ssh_known_hosts as hosts come and go at my site. I created a SSH key pair to serve as the CA key. I then set up Ansible to sign a host key with the CA using the openssh_cert module, add HostCertificate /path/to/signed_host_key to sshd_config, and reload sshd.

However, after I added the certificate key to ssh_known_hosts, I still get prompted to confirm the authenticity of the host. When I log in to the host and check the log, I see this error message:

error: No matching private key for certificate

What does that error message mean in the context of certificate signed keys? Signing only creates a cert-signed public key, and I know I'm not supposed to upload the CA private key to the host.

I searched for that error message, and got a bunch of generic discussions about creating keys or creating SSH certificates, or listings of the openssh source code if I searched with quotes around it.

已采纳解答

原帖链接 · edgewood · CC BY-SA 4.0

In the context of certificate signed host keys, that error message means that the signed host key doesn't match the corresponding host key. For example, if you generate a signed host key then fully recreate the host (creating a new host key), but still try to use the signed host key created against the old version of the host.

As of this writing, the Ansible openssh_cert module doesn't notice if the signing key or host key has changed. That means if you sign a host key and then the host key changes, openssh_cert will not notice. You have to force: yes to make it regenerate the signed host key against the updated host key.

(Self answering so that others will find this more easily. I eventually noticed that the host key files were newer than the signed host key files and figured out that openssh_cert wasn't regenerating the signed host key when the host key changed.)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-07-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。