Security team of my organization told us to disable weak ciphers due to they issue weak keys.


But I tried looking for these ciphers in ssh_config and sshd_config file but found them commented.

 grep arcfour *
ssh_config:#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc

Where else I should check to disable these ciphers from SSH?

  • 1
    for SSH server it will be in /etc/ssh/sshd_config and for the SSH client it will be in /etc/ssh/ssh_config. You want to look for the Cipher line in each, and for example have just Cipher aes256-ctr specified. Then restart SSH via /etc/init.d/sshd restart or via the equivalent systemd command. – ron Dec 5 '18 at 18:58
  • 1
    you want to become knowledgeable about all the parameters in sshd_config if you really care about SSH security, otherwise it can be all security theater. – ron Dec 5 '18 at 19:09
  • @ron the second comment is an intriguing one, can you illustrate with an example what you intend? – Jerome Dec 12 '18 at 12:26
  • 1
    the ciphers list is just one setting out of many for having SSH properly implemented... Protocol, PermitRootLogin, AuthorizedKeysFile, PermitEmptyPasswords, IgnoreRhosts, PermitTunnel, and so on. You can rely on their default settings as implemented in your linux distribution, but Ignornance is bliss only up until you have a problem – ron Dec 12 '18 at 16:29

If you have no explicit list of ciphers set in ssh_config using the Ciphers keyword, then the default value, according to man 5 ssh_config (client-side) and man 5 sshd_config (server-side), is:


Note the presence of the arcfour ciphers. So you may have to explicitly set a more restrictive value for Ciphers.

ssh -Q cipher from the client will tell you which schemes your client can support. Note that this list is not affected by the list of ciphers specified in ssh_config. Removing a cipher from ssh_config will not remove it from the output of ssh -Q cipher. Furthermore, using ssh with the -c option to explicitly specify a cipher will override the restricted list of ciphers that you set in ssh_config and possibly allow you to use a weak cipher. This is a feature that allows you to use your ssh client to communicate with obsolete SSH servers that do not support the newer stronger ciphers.

nmap --script ssh2-enum-algos -sV -p <port> <host> will tell you which schemes your server supports.

  • Hi , I mentioned specific ciphers in ssh_config and restarted ssh service but when I did ssh -Q cipher <hostname> I am still getting all ciphers that I am getting earlier irrespective of my configuration. – rɑːdʒɑ Dec 30 '16 at 10:30
  • 1
    I'm sorry, ssh_config is the client-side config, the server-side config is sshd_config, please try that. (It's also called Ciphers there.) – Ulrich Schwarz Dec 30 '16 at 10:42
  • Yeah I know but when I grep for ciphers I found them at ssh_config so I did changes there. As production server I am not doing anything I am not sure – rɑːdʒɑ Dec 30 '16 at 10:46
  • Note that the defaults may differ between distributions. – Jonas Schäfer Dec 30 '16 at 13:33
  • Seems there is no ssh -Q on older versions. (e.g. CentOS 6's openssh v5.3p1) – Tomofumi Nov 27 '18 at 2:58

To disable RC4 and use secure ciphers on SSH server, hard-code the following in /etc/ssh/sshd_config

ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr

OR if you prefer not to dictate ciphers but merely want to strip out insecure ciphers, run this on the command line instead (in sudo mode):

sshd -T | grep ciphers | sed -e "s/\(3des-cbc\|aes128-cbc\|aes192-cbc\|aes256-cbc\|arcfour\|arcfour128\|arcfour256\|blowfish-cbc\|cast128-cbc\|rijndael-cbc@lysator.liu.se\)\,\?//g" >> /etc/ssh/sshd_config

You can check ciphers currently used by your server with:

sudo sshd -T | grep ciphers | perl -pe 's/,/\n/g' | sort -u

Make sure your ssh client can use these ciphers, run

ssh -Q cipher | sort -u

to see the list.

You can also instruct your SSH client to negotiate only secure ciphers with remote servers. In /etc/ssh/ssh_config set:

Host *
    ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr

Above snippets come from here
To test your server's settings you can use ssh-audit


The problem with explicitly specifying a cipher list is that you must manually add new ciphers as they come out. Instead, simply list the ciphers you want to remove, prepending the list (not each individual cipher) with a '-' character. So in this case, the Ciphers line should read:

Ciphers -arcfour*

Or if you prefer:

Ciphers -arcfour,arcfour128,arcfour256

From the sshd_config man page on the Ciphers option (since OpenSSH 7.5, released 2017-03-20):

If the specified value begins with a ‘+’ character, then the specified ciphers will be appended to the default set instead of replacing them. If the specified value begins with a ‘-’ character, then the specified ciphers (including wildcards) will be removed from the default set instead of replacing them.

This also applies to the KexAlgorithms and MACs options.


How to disable a weak ssh cipher,100% working tested on Fedora 29. The problem: Nessus report my samba4 server use not strong ciphers aes256-cbc and aes128-cbc. So I put those lines in /etc/ssh/sshd_config

MACs hmac-sha2-512,hmac-sha2-256
Ciphers aes256-ctr,aes192-ctr,aes128-ctr
KexAlgorithms diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,curve25519-sha256,curve25519-sha256@libssh.org

Et voilà!..it still use the cbc cipher because this command work :(

ssh -c aes256-cbc samba4

So I check the useful systemd and I discover sshd service is using another file for ciphers


Backup the file for safety

cp /etc/crypto-policies/back-ends/opensshserver.config     /etc/crypto-policies/back-ends/opensshserver.config.old

Edit it,and remove the cbc cipher. Restart the service

systemctl restart sshd

And finally test,works fine..cbc disabled.

ssh -c aes256-cbc samba4
Unable to negotiate with port 22: no matching cipher found. Their offer: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr

enable/disable cipher need to add/remove it in file /etc/ssh/sshd_config After edit this file the service must be reloaded

systemctl reload sshd
/etc/init.d/sshd reload

Then,running this command from the client will tell you which schemes support

ssh -Q cipher

To check if arcfour cipher is enabled or not on the server run this command

ssh localhost -c arcfour

To check if arcfour128 cipher is enabled or not on the server,run this command

ssh localhost -c arcfour128
  • This step was missing in above answers – Saras Arya Jun 25 '19 at 12:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.