ãç°å¢ã
$ cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
$ ssh -V
OpenSSH_8.0p1, OpenSSL 1.1.1c FIPS 28 May 2019
Cent8 ã® /etc/ssh/sshd_config ã«ãCiphersããæå®ãã¦ããåæ ãããªããã»ã»ã»
ã¨ããç¸è«ãåããã®ã§ããã£ã¦ã¿ãã
ã¤ã³ã¹ãã¼ã«å¾ãç¹ã«è¨å®ãå¼ã£ã¦ããªã /etc/ssh/sshd_config ã«ã¦ã
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
ã®ããã«ããã¤ãè¨å®ãæ¸ãã¦ã¿ãããã©ããæå¹ã«ãªã£ã¦ããªãã
ã©ããCentOS 7ã¾ã§ã¨ã¯æ§åãéãï¼
次ã®ãããªæãã§æ¥ç¶ã試ãã¨ãsshd_config ã§è¨±å¯ãã¦ããªãCiphers ã§æ¥ç¶ãã¦ãã¾ã£ãã
$ ssh -c aes128-cbc localhost
sshd ãåèµ·åããã®å¿ããï¼ã¨ãä¸ç¬æã£ããã©ãããã§ã¯ãªãã£ãã®ã§ã
systemd å¨ããè¦ã¦ãããã¨ã«ããã
ã¾ãã¯ã/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 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
ã§ããã
ExecStart=/usr/sbin/sshd -D $OPTIONS $CRYPTO_POLICY
ãsshdã®èµ·åã³ãã³ãã
ããã»ã¹ãè¦ã¦ã¿ãã¨ã
# ps aux | grep sshd ã»ã»ã» root 2592 0.0 0.3 92968 6860 ? Ss 18:58 0:00 /usr/sbin/sshd -D -oCiphers=[email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc -oMACs=[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
ããããããé·ãã
åè¿°ã®ãã¡ã¤ã«ã«ãã£ãã-D $OPTIONS $CRYPTO_POLICYãã®é¨åã®ã©ã¡ãããé·ã訳ã§ãããå°ãè¦ã¦ã¿ããã¨ã«ã
/usr/lib/systemd/system/sshd.service ã®ä¸ã§ãé¢ä¿ããã®ã¯ä»¥ä¸ã®é¨åã
EnvironmentFile=-/etc/crypto-policies/back-ends/opensshserver.config EnvironmentFile=-/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS $CRYPTO_POLICY
EnvironmentFile ã§æå®ããããã¡ã¤ã«ãè¦ã¦ã¿ãã¨ã»ã»ã»
/etc/crypto-policies/back-ends/opensshserver.config ã¯ã
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_POLICY ãä¸è´ã§ãå
ã»ã©ã®psã³ãã³ãã®çµæã¨åãã
ãããããè¦ãã¨ãã-oCiphers=ãã§æå®ããããªãã·ã§ã³ãããã
sshdãèµ·åããéãè¨å®ãã¡ã¤ã«ï¼sshd_configï¼ãèªã¿è¾¼ããã®ã®ãsshd ã®èµ·åæã«ã³ãã³ãã©ã¤ã³ã§æå®ããããªãã·ã§ã³ã®æ¹ãåªå
ãããã
å¾ã£ã¦ãsshd_config ã« Ciphers ãè¨å®ãã¦ããæå¹ã«ãªã£ã¦ããªãã£ãã
ãã1ã¤ã®ãã¡ã¤ã«ã/etc/sysconfig/sshd ã¯ã
# Configuration file for the sshd service. # The server keys are automatically generated if they are missing. # To change the automatic creation, adjust sshd.service options for # example using systemctl enable [email protected] to allow creation # of DSA key or systemctl mask [email protected] to disable RSA key # creation. # Do not change this option unless you have hardware random # generator and you REALLY know what you are doing SSH_USE_STRONG_RNG=0 # SSH_USE_STRONG_RNG=1 # System-wide crypto policy: # To opt-out, uncomment the following line # CRYPTO_POLICY=
ã¨ãªã£ã¦ãã¦ãCRYPTO_POLICY ã¯ã³ã¡ã³ãè¡ã«ãªã£ã¦ããã
ã¤ãã§ã«ã
ExecStart=/usr/sbin/sshd -D $OPTIONS $CRYPTO_POLICY
ã«æ¸ããã¦ããå¤æ°å $OPTIONS ã¯è¦å½ãããªãã»ã»ã»
ãããä½ãã¯åããã(´ã»Ïã»`)
ã§ã¯ CRYPTO_POLICY ã£ã¦ä½ï¼ã¨ããäºã ãã©ã赤帽ã¨ã³ã¸ãã¢ããã®Blogã«è©³ãã解説ãããã®ã§åèã
rheb.hatenablog.com
åå ã¯åãã£ããã©ãã©ããã£ã¦å¯¾å¦ããï¼ã¨ããã®ã¯ã以ä¸ã®ãããããèããããã
- æ¹æ³ï¼ï¼crypto-policies ã DEFAULT ããé«ã»ãã¥ãªãã£ã¸å¤æ´
- æ¹æ³ï¼ï¼/etc/sysconfig/sshd ã« CRYPTO_POLICY= ã¨ç©ºæåãæå®ããsshd_config ã®è¨è¼ãæå¹ã«ãã
crypto-policies ãå¤æ´ããå ´å
ç¾ç¶ç¢ºèªã¨è¨å®å¤æ´ã¯ä»¥ä¸ã®éãã
ç¾ç¶ç¢ºèª # update-crypto-policies --show è¨å®å¤æ´ # update-crypto-policies --set FUTURE
/etc/crypto-policies/configããæ¸ãæãããããã
crypto-policies ãå¤æ´å¾ãsshd ãåèµ·åã㦠ps ã³ãã³ã㧠sshd ã®ã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ã確èªãã¦ã¿ãã
DEFAULTã®å ´å -oCiphers=[email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc FIPSã®å ´å -oCiphers=[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc FUTUREã®å ´å -oCiphers=[email protected],[email protected],aes256-ctr,aes256-cbc LEGACYã®å ´å -oCiphers=[email protected],[email protected],aes256-ctr,aes256-cbc,[email protected],aes128-ctr,aes128-cbc,3des-cbc
LEGACY ã ã¨ã3des ãåºã¦ããã
/etc/sysconfig/sshd ã« CRYPTO_POLICY= ã¨ç©ºæåãæå®ããsshd_config ã®è¨è¼ãæå¹ã«ããå ´å
ãã¡ãã®æ¹æ³ã¯ãCiphers ãç´°ããèªç±ã«è¨å®ã§ããã
ã¾ãããã®æ¹æ³ã®å ´åãMACs ã KexAlgorithms ãªã©ã$CRYPTO_POLICY ã®å¤æ°ã§æå®ããã¦ããé
ç®ã sshd_config ã§è¨å®ã§ããããã«ãªãã
/etc/sysconfig/sshd ã«ã¦
#CRYPTO_POLICY= ãâ CRYPTO_POLICY=
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
ãªã©ã¨ããsshd ãåèµ·åã
ãããã®å ´åãã以ä¸ã®ããã«åä½ç¢ºèªãã
$ ssh -c aes128-cbc localhost Unable to negotiate with 127.0.0.1 port 22: no matching cipher found. Their offer: [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
ã¤ãã§ã«ãæå®å¯è½ãªæå·åæ¹å¼ã¯ã以ä¸ã®ããã«ç¢ºèªã§ããã
$ ssh -Q cipher 3des-cbc aes128-cbc aes192-cbc aes256-cbc [email protected] aes128-ctr aes192-ctr aes256-ctr [email protected] [email protected] [email protected]