0

Disable Weak Key Exchange Algorithm, CBC Mode in SSH

 2 years ago
source link: https://blog.51cto.com/wemux/5576385
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Disable Weak Key Exchange Algorithm, CBC Mode in SSH

原创

wemux 2022-08-15 09:09:08 博主文章分类:Linux ©著作权

文章标签 SSH CBC 文章分类 Linux 系统/运维 yyds干货盘点 阅读数178

Backup /etc/sysconfig/sshd and /etc/ssh/sshd_config

cp /etc/sysconfig/sshd /etc/sysconfig/sshd.before
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.before

Edit /etc/sysconfig/sshd to uncomment the CRYPTO_POLICY setting

from:

# CRYPTO_POLICY=
CRYPTO_POLICY=

Copy the following ciphers, MACs, and KexAlgorithms to /etc/ssh/sshd_config.

KexAlgorithms [email protected],ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]

Verify the configuration file before restarting the SSH server.

sshd -t

If there are no errors reported, then restart the SSHD service.

systemctl restart sshd

Test weak CBC ciphers by executing the below command.

ssh -vv -oCiphers=3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc
<server>

If successful, it will prompt for a password. This means weak ciphers are enabled.

If it fails, indicating cbc ciphers are disabled, you should receive a message like this:

Unable to negotiate with 10.30.11.11 port 22: no matching cipher found.
Their offer: [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr

To test if weak MAC algorithms are enabled, run the below command:

ssh -vv -oMACs=hmac-md5,hmac-md5-96,hmac-sha1,hmac-sha1-96,[email protected],[email protected],[email protected],[email protected],[email protected] <server>

RHEL8 default ciphers include a number which have implicit MACs, testing like above will actually negotiate successfully and securely even though it would appear it is using hmac-md5. Look for the concluding negotiation where you will see something similar to:

debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK