报错代码:
GnuTLS: No or insufficient priorities were set.
Unable to establish SSL connection.
分析:
如果客户端和服务端的 TLS 版本不匹配,就会出现此类报错
解决方法:
# wget --secure-protocol=TLSv1 <URL>
GnuTLS: No or insufficient priorities were set.
Unable to establish SSL connection.
如果客户端和服务端的 TLS 版本不匹配,就会出现此类报错
# wget --secure-protocol=TLSv1 <URL>
# vim /etc/sysconfig/sshd
确保部分内容如下:
......
# CRYPTO_POLICY=
......
# vim /etc/crypto-policies/policies/modules/CUSTOMER.pmod
创建以下内容:
# SSH Ciphers, Key-Exchange, Hash-Algorithms
ssh_cipher = AES-128-GCM AES-256-GCM
key_exchange = ecdh-sha2-nistp256 ecdh-sha2-nistp384
mac = HMAC-SHA2-256 HMAC-SHA2-256
# Global Ciphers
cipher = AES-128-GCM AES-256-GCM
# Global Hash
hash = SHA2-256 SHA2-384
# Global TLS
tls_cipher = AES-128-GCM AES-256-GCM
protocol = TLS1.3 TLS1.2
min_tls_version = TLS1.2
# Parameter sizes
min_dh_size = 4096
min_dsa_size = 4096
min_rsa_size = 4096
(
补充:这里以设置:
1) 创建名为 CUSTOMER.pmod 的自定义 crypto policies 文件
2) SSH cipher 是 AES-128-GCM 和 AES-256-GCM,SSH key_exchange 是 ecdh-sha2-nistp256 和 ecdh-sha2-nistp384,SSH mac 是 HMAC-SHA2-256 和 HMAC-SHA2-256
3) 全局 cipher 是 AES-128-GCM 和 AES-256-GCM
4) 全局 Hash 是 SHA2-256 和 SHA2-384
5) 全局 TLS cipher 是 AES-128-GCM 和 AES-256-GCM,TLS 版本必须要高于 TLS1.2
6) 全局加密算法 dh 必须要高于或等于 4096 位,dsa 必须要高于或等于 4096 位,rsa 必须要高于 4096
为例
)
# update-crypto-policies --set DEFAULT:CUSTOMER
(补充:这里以选择名为 CUSTOMER.pmod 的自定义 crypto policies 文件为例)
# update-crypto-policies
# update-crypto-policies --show
DEFAULT:CUSTOMER
或者:
# cat /etc/crypto-policies/state/current
DEFAULT:CUSTOMER
(补充:这里显示选择了名为 CUSTOMER.pmod 的自定义 crypto policies 文件)
# startport=33000;endport=34000;for i in $(seq $startport $endport);do nc -lk $i &;done
(Add: Take start port is 33000 and end port is 34000 as an example here)
# for i in $(ps -aux | grep nc | grep '\-lk' | awk '{print $2}');do kill $i; done
# vim /etc/sysconfig/sshd
确保部分内容如下:
......
# CRYPTO_POLICY=
......
# cp /etc/crypto-policies/back-ends/opensshserver.config /etc/crypto-policies/back-ends/opensshserver.config.backup
# vim /etc/crypto-policies/back-ends/opensshserver.config
添加需要使用的 SSH 算法 (algorithms) 和加密方式 (ciphers):
(内容略)
(注意:如果需要使用的 SSH 加密方式 (cipher) 、信息验证代码 (message authentication code) 和算法 (algorithm) ,已包含在其中了则可以不用添加)
# printf "%s\n" $(source /etc/crypto-policies/back-ends/opensshserver.config; echo $CRYPTO_POLICY) | cut -c3-
Ciphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc
MACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512
GSSAPIKexAlgorithms=gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-
KexAlgorithms=curve25519-sha256,curve25519-sha256@libssh.org,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
HostKeyAlgorithms=ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com,ssh-rsa,ssh-rsa-cert-v01@openssh.com
PubkeyAcceptedKeyTypes=ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-256,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-512-cert-v01@openssh.com,ssh-rsa,ssh-rsa-cert-v01@openssh.com
CASignatureAlgorithms=ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-256,rsa-sha2-512,ssh-rsa
(补充:这里以显示 RHEL 8 默认使用的 SSH 加密方式 (cipher)、信息验证代码 (message authentication code) 和算法 (algorithm) 为例)
# systemctl restart sshd
# ssh -vv -oCiphers=3des-cbc -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 3des-cbc SSH 加密方式 (cipher) 为例)
# ssh -vv -oCiphers=3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 3des-cbc、aes128-cbc、aes192-cbc 和 aes256-cbc SSH 加密方式 (cipher) 为例)
# ssh -vv -oMACs=hmac-md5 -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 hmac-md5 SSH 信息验证代码 (message authentication code) 为例)
# ssh -vv -oMACs=hmac-md5,hmac-md5-96,hmac-sha1,hmac-sha1-96,hmac-md5-etm@openssh.com,hmac-md5-96-etm@openssh.com -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 hmac-md5、hmac-md5-96、hmac-sha1、hmac-sha1-96、hmac-md5-etm@openssh.com 和 hmac-md5-96-etm@openssh.com SSH 信息验证代码 (message authentication code) 为例)
# sshd -T | egrep -i "ciphers|macs"
# nmap --script ssh2-enum-algos -sV -p 22 127.0.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22 为例)
https://access.redhat.com/solutions/4410591
https://access.redhat.com/solutions/4278651
RHEL 8 的 SSH 加密算法默认会使用来自 crypto policies 系统的全局 SSH 加密算法,而此方法将让 SSH 使用单独设置的 SSH 加密算法。
# cp /etc/sysconfig/sshd /etc/sysconfig/sshd_backup
# vim /etc/sysconfig/sshd
将以下内容:
# CRYPTO_POLICY=
修改为:
......
CRYPTO_POLICY=
......
# cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup
# vim /etc/ssh/sshd_config
添加以下内容:
......
Ciphers aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512,hmac-sha2-256
KexAlgorithms ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256
(
补充:这里以使用:
1) aes256-ctr、aes192-ctr 和 aes128-ctr SSH 加密方式 (cipher)
2) hmac-sha2-512 和 hmac-sha2-256 SSH 信息验证代码 (message authentication code)
3) ecdh-sha2-nistp521、ecdh-sha2-nistp384、ecdh-sha2-nistp256 和 diffie-hellman-group-exchange-sha256 SSH 算法 (algorithm)
为例
)
# systemctl restart sshd
# ssh -vv -oCiphers=3des-cbc -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 3des-cbc SSH 加密方式 (cipher) 为例)
# ssh -vv -oCiphers=3des-cbc,aes128-cbc,aes192-cbc,aes256-cbc -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 3des-cbc、aes128-cbc、aes192-cbc 和 aes256-cbc SSH 加密方式 (cipher) 为例)
# ssh -vv -oMACs=hmac-md5 -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 hmac-md5 SSH 信息验证代码 (message authentication code) 为例)
# ssh -vv -oMACs=hmac-md5,hmac-md5-96,hmac-sha1,hmac-sha1-96,hmac-md5-etm@openssh.com,hmac-md5-96-etm@openssh.com -oPort=22 192.168.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22,有没有启用 hmac-md5、hmac-md5-96、hmac-sha1、hmac-sha1-96、hmac-md5-etm@openssh.com 和 hmac-md5-96-etm@openssh.com SSH 信息验证代码 (message authentication code) 为例)
# sshd -T | egrep -i "ciphers|macs"
# nmap --script ssh2-enum-algos -sV -p 22 127.0.0.1
(补充:这里以测试 IP 地址是 192.168.0.1,端口号是 22 为例)
https://access.redhat.com/solutions/4410591
https://access.redhat.com/solutions/4278651