Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux sshd 啟動報錯 Could not load host key 解決:重新產生 ED25519 主機金鑰

編輯:關於 Linux

新版 OpenSSH (6.5+) 預設啟用 ED25519 主機金鑰,升級後舊系統缺少 /etc/ssh/ssh_host_ed25519_key 導致 sshd 啟動失敗。解法:ssh-keygen -t ed25519 產生缺失金鑰並重啟服務。

sshd 金鑰錯誤示意圖

錯誤訊息

Could not load host key: /etc/ssh/ssh_host_ed25519_key

解決步驟

  1. 產生 ED25519 主機金鑰:
    ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
    # -N "" 空密碼 (主機金鑰不需密碼保護)
  2. 重啟 sshd:
    systemctl restart sshd
    # 或
    service sshd restart
    /etc/init.d/sshd restart
  3. 驗證:
    ssh -v localhost 2>&1 | grep "Server host key"
    # 應顯示 ED25519 金鑰指紋

補充:一次產生所有缺失主機金鑰

ssh-keygen -A
# 會檢查 /etc/ssh/ 下所有標準金鑰 (rsa, ecdsa, ed25519) 並產生缺失者

安全性建議

  • 定期輪換主機金鑰 (年度),並通知用戶更新 known_hosts
  • 停用弱金鑰類型:/etc/ssh/sshd_config 設定 HostKeyAlgorithms ssh-ed25519,rsa-sha2-512,rsa-sha2-256
  • 啟用 HostbasedAuthentication no、PermitRootLogin prohibit-password
Copyright © Windows教程網 All Rights Reserved