To check if an SSH server's public key is signed by a Certificate Authority (CA), you need to verify the SSH host certificate associated with the key. SSH certificates are used to authenticate hosts (or users) and are signed by a CA, similar to how TLS/SSL certificates work.
Here’s how you can verify if an SSH server’s public key is signed by a CA:
When connecting to an SSH server, the server may present:
ssh-rsa, ecdsa-sha2-nistp256, etc.)ssh-rsa-cert-v01@openssh.com)If the server uses a CA-signed certificate, the public key will be embedded in the certificate.
Run the following command to fetch the server’s host keys and certificates:
bashssh-keyscan <hostname_or_ip> 2>/dev/null | ssh-keygen -Lf -
<hostname_or_ip> with the server’s address.If the server uses a CA-signed certificate, the output will include:
host or user)Signed by CA: yes)Example output for a CA-signed certificate:
text<hostname_or_ip>: Type: ssh-rsa-cert-v01@openssh.com host certificate Public key: ssh-rsa AAAAB3NzaC1yc2EAAA... Signing CA: ssh-rsa AAAAB3NzaC1yc2EAAA... (using ssh-rsa) Valid: from 2024-01-01T00:00:00 to 2026-01-01T00:00:00 Principals: myhost.example.com Critical Options: (none) Extensions: (none)
Type: ... host certificate, the key is signed by a CA.ssh-rsa AAAAB3...), it is not signed by a CA.To explicitly verify the certificate, you need:
ca.pub)host-cert.pub)Run:
bashssh-keygen -s /path/to/ca.pub -n myhost.example.com /path/to/host-cert.pub
-s: Path to the CA’s public key.-n: Principal (hostname) to verify.If the certificate is not signed by the CA, you’ll see:
texthost-cert.pub is not signed by the CA!
On the SSH server, check /etc/ssh/sshd_config for:
iniHostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub
You can also inspect the certificate file directly:
bashssh-keygen -Lf /path/to/host-cert.pub
ssh-keyscan <host> | ssh-keygen -Lf -ssh-keygen -s ca.pub -n host host-cert.pubssh-keygen -Lf host-cert.pubssh-rsa AAAAB3...), it is not signed by a CA.ssh-rsa-cert-v01@openssh.com), it is signed by a CA.ssh-keygen -Lf to inspect certificates and ssh-keygen -s to verify them against a CA.Vibe can make mistakes. Check answers. Learn more