Update the SSH connection ciphers

The ciphers for ssh are configured in the /etc/ssh/sshd_config file so you will need to disable the deprecated ciphers by modifying lines in the sshd_config file.

First off make a backup of the existing config file.

cp /etc/ssh/sshd_config{,_bak}

Checking current ciphers

Run sshd -T | egrep -iw "ciphers|kexalgorithms" to get a list of the current ciphers

# sshd -T | egrep -iw "ciphers|kexalgorithms"
ciphers 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
kexalgorithms 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,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

Updating configuration and removing ciphers

Edit your sshd_config file and add in the lines ciphers and kexalgorithms from the previous output if the ciphers line already exists then you wont need to do this.

ciphers 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
kexalgorithms 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,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

Currently this will be using all the same ciphers, you will need to remove the ciphers that you no longer want to use for example you may want to remove aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc as these are classed as deprecated.

Change the ciphers and kexalgorithms line in the sshd_config file.

ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
kexalgorithms 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,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1

To apply the change restart the sshd service and check the ciphers then test you can still login by opening a new session.

# systemctl restart sshd
# sshd -T | egrep -iw "ciphers|kexalgorithms"
ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
kexalgorithms 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,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1

External test

Testing what is supported with nmap this may be helpful if you want to check from another source.

nmap --script ssh2-enum-algos -sV -p <port> <host>

Add a comment

0.0(0 votes)

Next Post Previous Post