如何在centos8上启用3des-cbc

如何在centos8上启用3des-cbc

由于某种原因,我必须在 centos8 服务器上使用 3des-cbc 加密。在 /etc/ssh/sshd_config 中我有这两行:

Ciphers 3des-cbc
KexAlgorithms diffie-hellman-group1-sha1

sshd -T | grep ciphers
ciphers 3des-cbc

ssh -vvv -c 3des-cbc [email protected]
OpenSSH_7.8p1, OpenSSL 1.1.1 FIPS  11 Sep 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 2: Including file /etc/crypto-policies/back-ends/openssh.config depth 1
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug3: gss kex names ok: [gss-gex-sha1-,gss-group14-sha1-]
debug3: kex names ok: [[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1]
debug1: /etc/ssh/ssh_config.d/05-redhat.conf line 8: Applying options for *
debug2: resolve_canonicalize: hostname 10.1.1.18 is address
debug2: ssh_connect_direct
debug1: Connecting to 10.1.1.18 [10.1.1.18] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.8
debug1: match: OpenSSH_7.8 pat OpenSSH* compat 0x04000000
debug2: fd 6 setting O_NONBLOCK
debug1: Authenticating to 10.1.1.18:22 as 'root'
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
debug2: host key algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: 3des-cbc
debug2: ciphers stoc: 3des-cbc
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: [email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc
debug2: ciphers stoc: [email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: [email protected]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
Unable to negotiate with 10.1.1.18 port 22: no matching cipher found. Their offer: [email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc

我不知道如何配置 sshd 以与 3des-cbc 一起使用。

问候,米贾

答案1

man sshd_config描述Ciphers.

在 Centos 8 上man sshd_config

 Ciphers
         Specifies the ciphers allowed.  Multiple ciphers must be comma-
         separated.  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.

         The supported ciphers are:

               3des-cbc
               aes128-cbc
               aes192-cbc
               aes256-cbc
               aes128-ctr
               aes192-ctr
               aes256-ctr
               [email protected]
               [email protected]
               [email protected]

         The default is handled system-wide by crypto-policies(7).  To see
         the defaults and how to modify this default, see manual page
         update-crypto-policies(8).

         The list of available ciphers may also be obtained using "ssh -Q
         cipher".

CentOS 8 指的是man crypto-policies,所以看那里。

在我的系统上,ls -l /etc/crypto-policies/back-ends | grep ssh给出了一条线索:

lrwxrwxrwx. 1 root root 45 Aug 14 20:36 libssh.config -> /usr/share/crypto-policies/DEFAULT/libssh.txt
lrwxrwxrwx. 1 root root 46 Aug 14 20:36 openssh.config -> /usr/share/crypto-policies/DEFAULT/openssh.txt
lrwxrwxrwx. 1 root root 52 Aug 14 20:36 opensshserver.config -> /usr/share/crypto-policies/DEFAULT/opensshserver.txt

$ cat /usr/share/crypto-policies/DEFAULT/opensshserver.txt
CRYPTO_POLICY='[email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc [email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha1,[email protected],hmac-sha2-512 -oGSSAPIKexAlgorithms=gss-gex-sha1-,gss-group14-sha1- -oKexAlgorithms=curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 -oHostKeyAlgorithms=rsa-sha2-256,[email protected],ecdsa-sha2-nistp256,[email protected],ecdsa-sha2-nistp384,[email protected],rsa-sha2-512,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],ssh-rsa,[email protected] -oPubkeyAcceptedKeyTypes=rsa-sha2-256,[email protected],ecdsa-sha2-nistp256,[email protected],ecdsa-sha2-nistp384,[email protected],rsa-sha2-512,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],ssh-rsa,[email protected] -oCASignatureAlgorithms=rsa-sha2-256,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,rsa-sha2-512,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsa'

手册页的这一段crypto-policies提示策略需要更改为LEGACY(另请参阅man update-crypto-policies:):

PROVIDED POLICY LEVELS
   LEGACY
       This policy ensures maximum compatibility with legacy systems; it
       is less secure and it includes support for TLS 1.0, TLS 1.1, and
       SSH2 protocols or later. The algorithms DSA, 3DES, and RC4 are
       allowed, while RSA and Diffie-Hellman parameters are accepted if
       larger than 1023 bits. The level provides at least 64-bit security.
       ·   MACs: all HMAC with SHA-1 or better + all modern MACs (Poly1305
           etc.)
       ·   Curves: all prime >= 255 bits (including Bernstein curves)
       ·   Signature algorithms: with SHA1 hash or better (DSA allowed)
       ·   TLS Ciphers: all available >= 112-bit key, >= 128-bit block
           (including RC4 and 3DES)
       ·   Non-TLS Ciphers: same as TLS ciphers with added Camellia
       ·   Key exchange: ECDHE, RSA, DHE
       ·   DH params size: >= 1023
       ·   RSA keys size: >= 1023
       ·   DSA params size: >= 1023
       ·   TLS protocols: TLS >= 1.0, DTLS >= 1.0

事实上,3des-cbc它存在于 LEGACY 文件中。

$ grep -l 3des-cbc /usr/share/crypto-policies/LEGACY/opensshserver.txt
/usr/share/crypto-policies/LEGACY/opensshserver.txt

或者,按照设置自定义策略的说明进行操作:

CUSTOM POLICIES
   The custom policies can take two forms. First form is a full custom
   policy file which is supported by the update-crypto-policies tool in
   the same way as the policies shipped along the tool in the package.

   The second form can be called a subpolicy or policy modifier. This form
   modifies aspects of any base policy file by removing or adding
   algorithms or protocols. The subpolicies can be appended on the
   update-crypto-policies --set command line to the base policy separated
   by the : character. There can be multiple subpolicies appended.

   Let’s suppose we have subpolicy NO-SHA1 that drops support for SHA1
   hash and subpolicy GOST that enables support for the various algorithms
   specified in Russian GOST standards. You can set the DEFAULT policy
   with disabled SHA1 support and enabled GOST support by running the
   following command:

   update-crypto-policies --set DEFAULT:NO-SHA1:GOST

   This command generates and applies configuration that will be
   modification of the DEFAULT policy with changes specified in the
   NO-SHA1 and GOST subpolicies.

或者,按照选择退出 forcrypto-policy的说明进行操作sshd

   ·   OpenSSH: Both server and client application inherits the cipher
       preferences, the key exchange algorithms as well as the GSSAPI key
       exchange algorithms. To opt-out from the policy for client,
       override the global ssh_config with a user-specific configuration
       in ~/.ssh/config. See ssh_config(5) for more information. To
       opt-out from the policy for server, uncomment the line containing
       CRYPTO_POLICY= in /etc/sysconfig/sshd .

在较旧的系统上,人们会在一行中查找并添加或删除密码/etc/ssh/sshd_config以偏离默认值,然后会导致sshd重新加载其配置。

例如,在 RHEL 7 上,Ciphers未指定默认值:

Ciphers [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc

在其中一个系统上,人们会询问是否有人3des-cbc通过添加密码行来删除,因为默认情况下它是打开的。

相关内容