← retour aux snippets

OpenSSH CA: signer des clés utilisateur/host

Créer une autorité SSH et signer des clés pour éviter la gestion des authorized_keys massive.

bash security #ssh#ca#certificates

objectif

Déployer une PKI SSH légère avec révocation simple via un fichier de principes (principals).

code minimal

# CA utilisateur
ssh-keygen -f ssh_user_ca -t ed25519 -N ''

# signer une clé utilisateur pour le principal 'deploy'
ssh-keygen -s ssh_user_ca -I deploy-2025 -n deploy -V +52w id_ed25519.pub

utilisation

# côté serveur: faire confiance à la CA utilisateur
echo 'TrustedUserCAKeys /etc/ssh/ssh_user_ca.pub' | sudo tee /etc/ssh/sshd_config.d/10-user-ca.conf
sudo systemctl restart sshd

variante(s) utile(s)

# CA hôte (pour éviter known_hosts sprawling)
ssh-keygen -f ssh_host_ca -t ed25519 -N ''
ssh-keygen -s ssh_host_ca -I app-01 -h -n app-01.data.pm /etc/ssh/ssh_host_ed25519_key.pub

notes

  • révoquez via un certificat court ou un principals file strict.
  • stockez les clés CA en sécurité, hors des hôtes standards.