centos8で3des-cbcを有効にする方法

centos8で3des-cbcを有効にする方法

何らかの理由でcentos8サーバーで3des-cbc暗号化を使用する必要があります。 /etc/ssh/sshd_config には次の 2 行があります。

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

3des-cbcで使用するようにsshdを設定する方法がわかりません。

ありがとう、ミザ

ベストアンサー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-cbcLEGACYファイルに存在します。

$ 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.

または、次の項目を選択解除するcrypto-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 .

以前のシステムでは、人々がデフォルトから離れるために1行でパスワードを見つけて追加または削除し/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

システムの1つはデフォルトでオンに3des-cbcなっているため、誰かがパスワード行を追加してそれを削除したかどうかを尋ねられました。

おすすめ記事