區域網環境 SSH 登入極慢(10-30 秒)或直接拒絕連接,經 ssh -v 定位為 DNS 反向解析與 GSSAPI 認證超時。
# 1. 禁用 GSSAPI 認證(消除 Kerberos 協商延遲)
GSSAPIAuthentication no
# 2. 禁用 DNS 反向解析(消除 PTR 查詢超時)
UseDNS no
# 3. 允許 Root 登入(視安全策略)
PermitRootLogin yes
# 重啟生效
systemctl restart sshd
# 或
service ssh restart
| 選項 | 預設 | 問題機制 | 影響 |
|---|---|---|---|
GSSAPIAuthentication | yes | 嘗試 Kerberos/GSSAPI 金鑰交換,需連接 KDC/AD 域控 | 無域環境下每次連接等待超時(10-20s) |
UseDNS | yes | 執行反向 DNS 查詢驗證客戶端 IP 對應主機名 | 無 PTR 記錄/DNS 故障時等待超時 |
Host *
GSSAPIAuthentication no
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
LogLevel ERROR
time ssh user@server 'echo ok'
# 應在 1-2 秒內完成,無明顯停頓
UseDNS yes、啟用 Fail2Ban、強制金鑰認證、修改非標準埠GSSAPIAuthentication 僅在 Kerberos 域環境有實際作用