Skener zranitelnosti Nessus byl ohlášen – SSH Weak Key Exchange Algorithms Enabled a SSH Server CBC Mode Ciphers Enabled. Podrobná zpráva naznačovala, že server SSH umožňuje algoritmy pro výměnu klíčů, které jsou považovány za slabé, a podporují šifrování Cipher Block Chaining (CBC), které může útočníkovi umožnit obnovit prostý text ze šifrovaného textu. No, tento tutoriál je o tom, jak deaktivovat slabé algoritmy výměny klíčů a režim šifrování CBC na serveru SSH na CentOS Stream 8.
Níže jsou snímky obrazovky přímo ze zprávy Nessus.
Jak deaktivovat algoritmus výměny slabého klíče a režim CBC v SSH
Krok 1: Upravte /etc/sysconfig/sshd a odkomentujte následující řádek.
#CRYPTO_POLICY=
do
CRYPTO_POLICY=
Tím se odhlásíte z kryptografických zásad nastavených serverem. Pokud chcete používat zásady šifrování v celém systému, měli byste napsat komentář CRYPTO_POLICY= a použijte update-crypto-policies příkaz pro zapnutí/vypnutí zásad. Další informace o zásadách kryptoměny.
Krok 2 :Zkopírujte následující šifry, MAC a KexAlgorithms do /etc/ssh/sshd_config .
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256 Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
Krok 3: Před restartováním serveru SSH ověřte konfigurační soubor.
sshd -t
Krok 4: Pokud nejsou hlášeny žádné chyby, restartujte službu SSHD.
# systemctl restart sshd
Krok 5: Otestujte slabé CBC šifry provedením níže uvedeného příkazu.
ssh -vv -oCiphers=3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc [user@server-ip]
Například:
$ ssh -vv -oCiphers=3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc centos@192.168.10.141 ::::::::::::::::::::::::::::::::::::::: debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512 debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,umac-128@openssh.com,hmac-sha2-512 debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,umac-128@openssh.com,hmac-sha2-512 debug2: compression ctos: none,zlib@openssh.com debug2: compression stoc: none,zlib@openssh.com debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 Unable to negotiate with 192.168.10.141 port 22: no matching cipher found. Their offer: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
Výše uvedená chyba znamená, že slabé šifry jsou zakázány. V případě, že se zobrazí výzva k zadání hesla, znamená to, že jsou povoleny slabé šifry.