今天从服务器 A(CentOS 7.3)配置 SSH 无密码登录服务器 B(CentOS Steam 9),发现执行以下常规操作后无法实现:
$ ssh-keygen
$ ssh-copy-id -i ~/.ssh/id_rsa.pub shenweiyan@66.xx.xx.xx # ssh-copy-id user@rhel-9-server-IP
$ ssh shenweiyan@66.xx.xx.xx
SSH 免密码登录不起作用
后来,更换 ecdsa 算法,问题才解决:
$ ssh-keygen -t ecdsa
$ ssh-copy-id -i ~/.ssh/id_ecdsa.pub shenweiyan@66.xx.xx.xx
ssh-keygen 更换 ecdsa 算法
根本原因就在于 SHA-1 已经在 RHEL9 中弃用了!
从 RHEL9 的官网文档《1.0.2. Crypto-policies, RHEL core cryptographic components, and protocols(加密策略、RHEL 核心加密组件和协议)》可以看到 SHA-1 已经在 RHEL9 中弃用了!
In RHEL 9, SHA-1 usage for signatures is restricted in the DEFAULT system-wide cryptographic policy. Except for HMAC, SHA-1 is no longer allowed in TLS, DTLS, SSH, IKEv2, DNSSEC, and Kerberos protocols. Individual applications not controlled by the RHEL system-wide crypto policies are also moving away from using SHA-1 hashes in RHEL 9.
在 RHEL 9 中,用于签名的 SHA-1 用法在 DEFAULT 系统范围的加密策略中受到限制。除 HMAC 外,TLS、DTLS、SSH、IKEv2、DNSSEC 和 Kerberos 协议中不再允许使用 SHA-1。不受 RHEL 系统范围的加密策略控制的单个应用程序在 RHEL 9 中也不再使用 SHA-1 hashes。