SSH: How to disable weak ciphers? The 2019 Stack Overflow Developer Survey Results Are Inssh...

Geography at the pixel level

I see my dog run

If the Wish spell is used to duplicate the effect of Simulacrum, are existing duplicates destroyed?

What does "rabbited" mean/imply in this sentence?

Can't find the latex code for the ⍎ (down tack jot) symbol

Confusion about non-derivable continuous functions

Where does the "burst of radiance" from Holy Weapon originate?

Springs with some finite mass

How to deal with fear of taking dependencies

Any good smartcontract for "business calendar" oracles?

aging parents with no investments

How can I create a character who can assume the widest possible range of creature sizes?

Why isn't airport relocation done gradually?

How can I fix this gap between bookcases I made?

Why is the maximum length of openwrt’s root password 8 characters?

What is the motivation for a law requiring 2 parties to consent for recording a conversation

It's possible to achieve negative score?

Is bread bad for ducks?

Can I write a for loop that iterates over both collections and arrays?

What tool would a Roman-age civilization have to grind silver and other metals into dust?

How to change the limits of integration

What is this 4-propeller plane?

If a poisoned arrow's piercing damage is reduced to 0, do you still get poisoned?

Is it possible for the two major parties in the UK to form a coalition with each other instead of a much smaller party?



SSH: How to disable weak ciphers?



The 2019 Stack Overflow Developer Survey Results Are Inssh Unable to negotiate: “no matching cipher found”, is rejecting cbcImplementation of eSTREAM ciphers available?Specifying ciphers and protocol 2 in .ssh/configDisable authentification for sshCreating a linux user with limited privileges for ssh tunnellingSolaris 10: how to enable some cipher or esclude weak cipher on ssh?Being Prompted for Password After Already Registered Public Key On serverJumphost suddenly reseting first SSH MUX connection attemptsMake new user able to login via sshHow to install weak cipher to connect to legacy SSH servers?Locking account password and instead use RSA key





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







40















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



  arcfour
arcfour128
arcfour256


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?










share|improve this question

























  • 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











  • 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













  • 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


















40















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



  arcfour
arcfour128
arcfour256


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?










share|improve this question

























  • 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











  • 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













  • 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














40












40








40


16






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



  arcfour
arcfour128
arcfour256


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?










share|improve this question
















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



  arcfour
arcfour128
arcfour256


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?







ssh encryption






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 30 '16 at 12:06









Jeff Schaller

44.8k1164146




44.8k1164146










asked Dec 30 '16 at 9:29









rɑːdʒɑrɑːdʒɑ

2,66472753




2,66472753













  • 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











  • 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













  • 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



















  • 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











  • 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













  • 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

















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





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













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





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







@ron the second comment is an intriguing one, can you illustrate with an example what you intend?

– Jerome
Dec 12 '18 at 12:26















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





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










5 Answers
5






active

oldest

votes


















35














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:



            aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
aes128-gcm@openssh.com,aes256-gcm@openssh.com,
chacha20-poly1305@openssh.com,
aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
aes256-cbc,arcfour


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.






share|improve this answer


























  • 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



















26














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






share|improve this answer

































    14














    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.






    share|improve this answer

































      1














      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





      share|improve this answer

































        0














        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



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


        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 192.168.0.48 port 22: no matching cipher found. Their offer: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr





        share|improve this answer
























          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f333728%2fssh-how-to-disable-weak-ciphers%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          35














          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:



                      aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
          aes128-gcm@openssh.com,aes256-gcm@openssh.com,
          chacha20-poly1305@openssh.com,
          aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
          aes256-cbc,arcfour


          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.






          share|improve this answer


























          • 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
















          35














          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:



                      aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
          aes128-gcm@openssh.com,aes256-gcm@openssh.com,
          chacha20-poly1305@openssh.com,
          aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
          aes256-cbc,arcfour


          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.






          share|improve this answer


























          • 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














          35












          35








          35







          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:



                      aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
          aes128-gcm@openssh.com,aes256-gcm@openssh.com,
          chacha20-poly1305@openssh.com,
          aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
          aes256-cbc,arcfour


          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.






          share|improve this answer















          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:



                      aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,
          aes128-gcm@openssh.com,aes256-gcm@openssh.com,
          chacha20-poly1305@openssh.com,
          aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,
          aes256-cbc,arcfour


          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.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 5 '18 at 15:27









          Jonathan Ben-Avraham

          1,69121619




          1,69121619










          answered Dec 30 '16 at 9:35









          Ulrich SchwarzUlrich Schwarz

          10.1k13249




          10.1k13249













          • 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



















          • 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

















          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





          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




          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





          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





          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





          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





          Seems there is no ssh -Q on older versions. (e.g. CentOS 6's openssh v5.3p1)

          – Tomofumi
          Nov 27 '18 at 2:58













          26














          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






          share|improve this answer






























            26














            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






            share|improve this answer




























              26












              26








              26







              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






              share|improve this answer















              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







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 19 '18 at 20:13









              Mark Stosberg

              4,0381226




              4,0381226










              answered Dec 30 '16 at 12:59









              savageBumsavageBum

              36925




              36925























                  14














                  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.






                  share|improve this answer






























                    14














                    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.






                    share|improve this answer




























                      14












                      14








                      14







                      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.






                      share|improve this answer















                      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.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Dec 12 '17 at 14:26

























                      answered Dec 11 '17 at 17:38









                      SpacedogSpacedog

                      19614




                      19614























                          1














                          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





                          share|improve this answer






























                            1














                            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





                            share|improve this answer




























                              1












                              1








                              1







                              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





                              share|improve this answer















                              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






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited yesterday









                              elbarna

                              4,275124087




                              4,275124087










                              answered Oct 9 '18 at 11:20









                              KumarKumar

                              211




                              211























                                  0














                                  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



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


                                  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 192.168.0.48 port 22: no matching cipher found. Their offer: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr





                                  share|improve this answer




























                                    0














                                    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



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


                                    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 192.168.0.48 port 22: no matching cipher found. Their offer: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr





                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      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



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


                                      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 192.168.0.48 port 22: no matching cipher found. Their offer: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr





                                      share|improve this answer













                                      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



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


                                      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 192.168.0.48 port 22: no matching cipher found. Their offer: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes128-gcm@openssh.com,aes128-ctr






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered yesterday









                                      elbarnaelbarna

                                      4,275124087




                                      4,275124087






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f333728%2fssh-how-to-disable-weak-ciphers%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

                                          The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

                                          Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...