解決SSH登入VMware vCenter Server出現”Too many authentication failures”錯誤

問題描述

最近在使用 SSH 登入VMware vCenter Server 時,遇到以下錯誤:

➜  ~ ssh [email protected]
Received disconnect from 192.168.10.10 port 22:2: Too many authentication failures
Disconnected from 192.168.10.10 port 22

透過查看詳細的 SSH 連線日誌,我並沒有指定但是系統一直嘗試使用公鑰進行身份驗證,導致無法成功登入:

➜  ~ ssh -v [email protected]
...
debug1: Authentications that can continue: publickey,keyboard-interactive
...
Received disconnect from 192.168.10.10 port 22:2: Too many authentication failures
Disconnected from 192.168.10.10 port 22

問題分析

在 SSH 連線嘗試中,系統一直嘗試使用 SSH 金鑰進行身份驗證,但由於認證失敗次數過多,導致連線被拒絕。解決此問題的方法是禁用 SSH 公鑰身份驗證,強制系統使用密碼進行身份驗證。

解決方法

使用以下命令,在 SSH 連線時禁用公鑰身份驗證:

➜  ~ ssh -o PubkeyAuthentication=no [email protected]
([email protected]) Password:
The time and date of this login have been sent to the system logs.

WARNING:
   All commands run on the ESXi shell are logged and may be included in
   support bundles. Do not provide passwords directly on the command line.
   Most tools can prompt for secrets or accept them from standard input.

VMware offers supported, powerful system administration tools.  Please
see www.vmware.com/go/sysadmintools for details.

The ESXi Shell can be disabled by an administrative user. See the
vSphere Security documentation for more information.
[root@localhost:~]

在上述命令中,透過使用 -o PubkeyAuthentication=no 選項,明確指定不使用公鑰身份驗證。然後,系統會提示輸入密碼進行身份驗證。

如果有需要還可以添加其他 SSH 參數以進一步調整連線行為。例如,您可以使用 -o LogLevel=DEBUG 以增加詳細的日誌輸出,或使用 -o ServerAliveInterval=60 來保持連線狀態。

➜  ~ ssh -o PubkeyAuthentication=no -o LogLevel=DEBUG -o ServerAliveInterval=60 [email protected]

這種解決方法有效地規避了由於公鑰身份驗證失敗導致的連線問題,確保能夠成功登入到 VMware vCenter Server。