Retour au cours

sécurité côté client

Durcissez le client: vérification stricte des hôtes et refus de mots de passe si non souhaité.

objectifs d’apprentissage

  • Activer StrictHostKeyChecking.
  • Refuser l’auth par mot de passe.
  • Limiter l’agent forwarding.

prérequis

  • Accès à ~/.ssh/config.
  • Cible de test.

notions clés

  • StrictHostKeyChecking yes.
  • PasswordAuthentication no (client).
  • ForwardAgent.

démonstration guidée

étape 1

Options strictes pour un host sensible.

cat >> ~/.ssh/config << 'EOF'
Host prod-*
  StrictHostKeyChecking yes
  PasswordAuthentication no
  ForwardAgent no
EOF

étape 2

Tester la connexion avec refus d’agent forwarding.

ssh -o ForwardAgent=no prod-app 'env | grep -i ssh' || true

exercice

Activez HashKnownHosts yes et observez le fichier known_hosts.

correction

Activation du hashage.

ssh-keygen -H -f ~/.ssh/known_hosts || true

quiz éclair

  1. Quelle option refuse l’usage de mot de passe côté client ?
  • a) PasswordAuthentication no
  • b) PubkeyAuthentication no
  • c) KbdInteractiveAuthentication yes

ressources