Questo post mostrerà come disabilitare HMAC MD5 e le cifre CBC come esempio per CentOS/RHEL 6 e 7.
Per CentOS/RHEL 7
Per ulteriori informazioni, consultare le pagine man:
# man sshd_config
Cifre
Specifica le cifre consentite. Più cifrari devono essere separati da virgole. Se il valore specificato inizia con un carattere '+', le cifre specificate verranno aggiunte al set predefinito invece di sostituirle.
I codici supportati sono:
3des-cbc aes128-cbc aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr aes128-gcm@openssh.com aes256-gcm@openssh.com arcfour arcfour128 arcfour256 blowfish-cbc cast128-cbc chacha20-poly1305@openssh.com
L'impostazione predefinita è:
chacha20-poly1305@openssh.com, aes128-ctr,aes192-ctr,aes256-ctr, aes128-gcm@openssh.com,aes256-gcm@openssh.com, aes128-cbc,aes192-cbc,aes256-cbc, blowfish-cbc,cast128-cbc,3des-cbc
L'elenco dei codici disponibili può essere ottenuto anche utilizzando "ssh -Q cipher". Ad esempio:
# ssh -Q cipher 3des-cbc blowfish-cbc cast128-cbc arcfour arcfour128 arcfour256 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
Per disabilitare i cifrari CBC, aggiorna /etc/ssh/sshd_config con i cifrari che sono richiesti tranne i cifrari CBC.
Per disabilitare CBC:
Ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
Riavvia il servizio sshd dopo aver apportato le modifiche.
# systemctl restart sshd
MAC
MAC Specifica gli algoritmi MAC (codice di autenticazione del messaggio) disponibili. L'algoritmo MAC viene utilizzato per la protezione dell'integrità dei dati. Più algoritmi devono essere separati da virgole. Se il valore specificato inizia con un carattere '+', gli algoritmi specificati verranno aggiunti al set predefinito invece di sostituirli.
Gli algoritmi che contengono "-etm" calcolano il MAC dopo la crittografia (encrypt-then-mac). Questi sono considerati più sicuri e il loro uso raccomandato. I MAC supportati sono:
hmac-md5 hmac-md5-96 hmac-ripemd160 hmac-sha1 hmac-sha1-96 hmac-sha2-256 hmac-sha2-512 umac-64@openssh.com umac-128@openssh.com hmac-md5-etm@openssh.com hmac-md5-96-etm@openssh.com hmac-ripemd160-etm@openssh.com hmac-sha1-etm@openssh.com hmac-sha1-96-etm@openssh.com hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com umac-64-etm@openssh.com umac-128-etm@openssh.com
L'impostazione predefinita è:
umac-64-etm@openssh.com,umac-128-etm@openssh.com, hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com, hmac-sha1-etm@openssh.com, umac-64@openssh.com,umac-128@openssh.com, hmac-sha2-256,hmac-sha2-512,hmac-sha1, hmac-sha1-etm@openssh.com
L'elenco degli algoritmi MAC disponibili può essere ottenuto anche utilizzando "ssh -Q mac". Ad esempio:
# ssh -Q mac hmac-sha1 hmac-sha1-96 hmac-sha2-256 hmac-sha2-512 hmac-md5 hmac-md5-96 hmac-ripemd160 hmac-ripemd160@openssh.com umac-64@openssh.com umac-128@openssh.com hmac-sha1-etm@openssh.com hmac-sha1-96-etm@openssh.com hmac-sha2-256-etm@openssh.com hmac-sha2-512-etm@openssh.com hmac-md5-etm@openssh.com hmac-md5-96-etm@openssh.com hmac-ripemd160-etm@openssh.com umac-64-etm@openssh.com umac-128-etm@openssh.com
Per disabilitare gli algoritmi dei MAC hmac-md5, aggiorna /etc/ssh/sshd_config con i Mac richiesti eccetto hmac-md5 per ecample:
MACs hmac-sha1-etm@openssh.com,umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160
Riavvia il servizio sshd dopo aver apportato le modifiche.
# systemctl restart sshd
Per CentOS/RHEL 6
In CentOS/RHEL 6 i comandi per elencare le cifrature ei MAC disponibili sono “sshd -T | cifrari grep | perl -pe 's/,/\n/g' | sort -u" e "nmap -vv –script=ssh2-enum-algos.nse -p 22 localhost":
# sshd -T | grep ciphers | perl -pe 's/,/\n/g' | sort -u nmap -vv --script=ssh2-enum-algos.nse -p 22 localhost
Per ulteriori informazioni, consultare le pagine man:
# man sshd_config
Cifre
Specifica le crittografie consentite per il protocollo versione 2. Più crittografie devono essere separate da virgole. I codici supportati sono:
3des-cbc aes128-cbc aes192-cbc aes256-cbc aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour blowfish-cbc rijndael-cbc@lysator.liu.se cast128-cbc
L'impostazione predefinita è:
aes128-ctr aes192-ctr aes256-ctr arcfour256 arcfour128 aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc arcfour rijndael-cbc@lysator.liu.se
Per disabilitare i cifrari CBC, aggiorna /etc/ssh/sshd_config con i cifrari richiesti eccetto i cifrari CBC.
Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,arcfour
Riavvia il servizio sshd dopo aver apportato le modifiche.
# service sshd restart
MAC
MAC Specifica gli algoritmi MAC (codice di autenticazione del messaggio) disponibili. L'algoritmo MAC viene utilizzato nel protocollo versione 2 per la protezione dell'integrità dei dati. Più algoritmi devono essere separati da virgole. L'impostazione predefinita è:
hmac-md5,hmac-sha1,umac-64@openssh.com, hmac-ripemd160,hmac-sha1-96,hmac-md5-96, hmac-sha2-256,hmac-sha2-512,hmac-ripemd160@openssh.com
Per disabilitare gli algoritmi dei MAC hmac-md5, aggiorna /etc/ssh/sshd_config con i Mac richiesti eccetto hmac-md5 per ecample:
MACs hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160@openssh.com
Riavvia il servizio sshd dopo aver apportato le modifiche:
# service sshd restartCome disabilitare crittografia debole e algoritmi HMAC non sicuri nei servizi SSH in CentOS/RHEL 8