Problème avec OpenSSh Server
Suite à la migration Debian 9 => 10, il est possible que le service sshd ne redémarrare plus. Des erreurs sont alors trouvées dans les logs :
Starting OpenBSD Secure Shell server...
/etc/ssh/sshd_config line 17: Deprecated option UsePrivilegeSeparation
/etc/ssh/sshd_config line 36: Deprecated option RSAAuthentication
/etc/ssh/sshd_config line 102: Bad SSH2 cipher spec 'aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128, \
aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc, \
blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se'.
Failed to start OpenBSD Secure Shell server.
Concernant les erreurs "Deprecated option", il suffit de commenter ou supprimer les lignes concernées.
Concernant l'erreur sur la liste des algorithmes de chiffrement ("Bad SSH2 cipher spec"), la difficulté consiste à trouver l'algorithme qui n'est pas accepté. Pour cela, on peur s'aider des commandes suivantes :
# On récupère dans les logs la liste des algorithmes, et on la reformate
# en remplaçant les "," par des " " :
# sed -e => -e script, --expression=script : add the script to the commands to be executed
$ echo 'aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-gcm@openssh.com,aes256-gcm@openssh.com, \
chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour, \
rijndael-cbc@lysator.liu.se' | sed -e "s/,/ /g"
aes128-ctr aes192-ctr aes256-ctr arcfour256 arcfour128 aes128-gcm@openssh.com aes256-gcm@openssh.com \
chacha20-poly1305@openssh.com aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc arcfour \
rijndael-cbc@lysator.liu.se
# On utilise la liste reformatée avec la commande "sshd" pour savoir quels sont les algorithmes non supportés
# sshd -t -o => -t : Test mode. Only check the validity of the configuration file and sanity of the keys.
# -o option : Can be used to give options in the format used in the configuration file.
$ for c in aes128-ctr aes192-ctr aes256-ctr arcfour256 arcfour128 aes128-gcm@openssh.com aes256-gcm@openssh.com \
chacha20-poly1305@openssh.com aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc arcfour \
rijndael-cbc@lysator.liu.se; do
> sshd -t -o Ciphers=$c
> done
command-line line 0: Bad SSH2 cipher spec 'arcfour256'.
command-line line 0: Bad SSH2 cipher spec 'arcfour128'.
command-line line 0: Bad SSH2 cipher spec 'blowfish-cbc'.
command-line line 0: Bad SSH2 cipher spec 'cast128-cbc'.
command-line line 0: Bad SSH2 cipher spec 'arcfour'.
On obtient de cette manière les noms des algorithmes de chiffrement à retirer de la ligne "Ciphers" dans le fichier "/opt/ssh/etc/sshd_config". On peut également pour confirmation utiliser la commande suivante, qui teste la validité du fichier de configuration :
# sshd -T => -T : Extended test mode. Check the validity of the configuration file, output the effective configuration to std‐out and then exit $ sshd -T | grep ciphers ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
Par ailleurs, on peut vérifier la liste des algorithmes de chiffrement valides au moyen de la commande "ssh -Q" :
# ssh -Q => -Q query_option : # Queries ssh for the algorithms supported for the specified version 2. The available features are: cipher # (supported symmetric ciphers), cipher-auth (supported symmetric ciphers that support authenticated # encryption), help (supported query terms for use with the -Q flag), mac (supported message integrity codes), # kex (key exchange algorithms), key (key types), key-cert (certificate key types), key-plain (non-certificate key # types), protocol-version (supported SSH protocol versions), and sig (supported signature algorithms). $ ssh -Q cipher 3des-cbc aes128-cbc aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se aes128-ctr aes192-ctr aes256-ctr aes128-gcm@openssh.com aes256-gcm@openssh.com chacha20-poly1305@openssh.com
Si, après modification du fichier "/opt/ssh/etc/sshd_config", le démarrage du démon sshd ("service sshd start") n'aboutit toujours pas, on peut tenter en désespoir de cause d'utiliser cette liste minimale d'algorithmes de chiffrement dans le fichier "/opt/ssh/etc/sshd_config" :
Ciphers +aes256-cbc,aes192-cbc,aes128-cbc