Hello all, How to Set up a Certificate Authority (CA) Server to enable certificate-based authentication for SSH Servers.
Thanks in advance. ![]()
Computeman
Hello all, How to Set up a Certificate Authority (CA) Server to enable certificate-based authentication for SSH Servers.
Thanks in advance. ![]()
Computeman
Install SSH on the CA server as follows.
yum install -y openssh-server openssh-clients
Set up a dedicated working directory for the CA and switch into it.
mkdir /root/ssh_cert
cd /root/ssh_cert
Generate a CA key as follows.
ssh-keygen -f cert_ca
Verify the key fies.
ls
The output should be.
cert_ca cert_ca.pub
On the CA server execute.
scp cert_ca.pub root@sshserver:/etc/ssh/
Replace sshserver with the actual hostname or IP address of your SSH server.
On the SSH server, execute.
# vi /etc/ssh/sshd_config
And add the following line.
TrustedUserCAKeys /etc/ssh/cert_ca.pub
Save the changes and restart SSH service.
# systemctl restart sshd
On the CA server, execute.
# ssh-keygen -t rsa -b 4096 -f user1_id_rsa
Sign the client public key with the CA key
# ssh-keygen -s cert_ca -I user_user1 -n user1 -V +52w user1_id_rsa.pub
Output is as follows.
Signed user key user1_id_rsa-cert.pub: id "user_user1" serial 0 for user1 valid from 2026-04-17T10:09:00 to 2026-08-17T10:08:10
Where,
Following files will be created.
ls
Output is as follows.
cert_ca.pub
cert_ca
user1_id_rsa.pub
user1_id_rsa
user1_id_rsa-cert.pub
On the CA Server run.
# scp user1_id_rsa user1_id_rsa-cert.pub root@clientserver:/home/user1/.ssh/
Replace clientserver with the real hostname or IP address of your client server.
On the client server run.
chown user1:user1 /home/user1/.ssh/user1_id_rsa
chown user1:user1 /home/user1/.ssh/user1_id_rsa-cert.pub
chmod 600 /home/user1/.ssh/user1_id_rsa
chmod 644 /home/user1/.ssh/user1_id_rsa-cert.pub
Connect to the SSH server using the signed certificate.
ssh -i .ssh/user1_id_rsa sshserver
Substitute sshserver for your actual SSH server name or IP Address.
Check the /var/log/secure file on the SSH server.
cat /var/log/secure | grep user1
Expected output is.
Accepted publickey for user1 from 192.168.1.44 port 4598 ssh2: RSA-CERT SHA256:LdkD86 ID user_user1 (serial 0) CA RSA SHA256:Ej9T8M
Notice the RSA-CERT reference, which confirms that user1 is authenticating using the CA-signed certificate.
This configuration enables a dedicated CA server to handle SSH certificate signing, while all SSH servers are set to trust that CA for verifying authentication.
Let me know if you need more info or needs troubleshooting.
Bye ![]()