Ciphers, MACs or KeX algorithms differ from "sshd -T" to what is provided by current crypto policy level
Environment
- Red Hat Enterprise Server (RHEL) 8
openssh-server
Issue
-
While comparing the output of
sshd -Twith the Ciphers, MACs or Key Exchange Algorithms from the current crypto policy configured, some inconsistencies can be noted:# sshd -T | grep -i ciphers ciphers chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com # cat /etc/crypto-policies/back-ends/opensshserver.config | cut -f 2 -d \' | cut -f 1 -d " " -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc # update-crypto-policies --show DEFAULT -
aes192-ctrshould not be available for theDEFAULTlevel.
Resolution
-
Manually load crypto policy file as extra argument for
sshd -T, placing the contents ofCRYPTO_POLICY=''at the end of the command line:# sshd -T `sed -e s/CRYPTO_POLICY\=//g -e s/\'//g /etc/crypto-policies/back-ends/opensshserver.config` -
Loading
/etc/crypto-policies/back-ends/opensshserver.configis enough to provide a visually accurate output that matches the currently configured crypto policy. Examples:# update-crypto-policies --show DEFAULT # sshd -T `sed -e s/CRYPTO_POLICY\=//g -e s/\'//g /etc/crypto-policies/back-ends/opensshserver.config`| grep cipher ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc # update-crypto-policies --set FUTURE Setting system policy to FUTURE Note: System-wide crypto policies are applied on application start-up. It is recommended to restart the system for the change of policies to fully take place. # sshd -T `sed -e s/CRYPTO_POLICY\=//g -e s/\'//g /etc/crypto-policies/back-ends/opensshserver.config`| grep cipher ciphers aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr
Root Cause
This difference between the output provided by sshd -T and crypto policies is expected, because the upstream openssh project is not developed to support Red Hat provided Strong crypto defaults in RHEL8. Crypto policies are applied to sshd.service unit as an EnvironmentFile during it's start.
# systemctl cat sshd.service
# /usr/lib/systemd/system/sshd.service
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.target
Wants=sshd-keygen.target
[Service]
Type=notify
EnvironmentFile=-/etc/crypto-policies/back-ends/opensshserver.config <<<---HERE
EnvironmentFile=-/etc/sysconfig/sshd
ExecStart=/usr/sbin/sshd -D $OPTIONS $CRYPTO_POLICY
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
/etc/crypto-policies/back-ends/opensshserver.config is a symbolic link to the current configured crypto policy level, and will be loaded directly by sshd service.
# ls -l /etc/crypto-policies/back-ends/opensshserver.config
lrwxrwxrwx. 1 root root 52 Feb 4 13:57 /etc/crypto-policies/back-ends/opensshserver.config -> /usr/share/crypto-policies/DEFAULT/opensshserver.txt
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.