SSH 連線已在連接埠 22 上建立,但服務無法運作

SSH 連線已在連接埠 22 上建立,但服務無法運作

我的一台 MySQL 叢集伺服器上經常遇到這個問題,實際上總是發生在該叢集的任何隨機 MySQL 伺服器上,在我們擁有相同配置的許多國家/地區。

我有一個可以 ping 通的「dbX Node」:

$ ping 192.0.2.4
PING 192.0.2.4 (192.0.2.4) 56(84) bytes of data.
64 bytes from 192.0.2.4: icmp_seq=1 ttl=61 time=1.92 ms
64 bytes from 192.0.2.4: icmp_seq=2 ttl=61 time=2.46 ms

我可以 Telnet TCP 連接埠 22:

telnet 192.0.2.4 22
Trying 192.0.2.4 ...
Connected to 192.0.2.4.
Escape character is '^]'.

並立即關閉:

Connection closed by foreign host.

顯然,SSH 本身不起作用:

debug1: Connection established.
debug1: identity file /home/user/.ssh/identity type -1
debug3: Not a RSA1 key file /home/user/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/user/.ssh/id_rsa type 1
debug1: identity file /home/user/.ssh/id_dsa type -1
ssh_exchange_identification: Connection closed by remote host

我還可以 telnet 到 MySQL 連接埠:

# telnet db5 3306
Trying 192.0.2.4...
Connected to db5 (192.0.2.4).
Escape character is '^]'.

但無法連接到它:

# mysql -h db5 -uroot

該伺服器是執行 RHEL 5.5 的 ProLiant DL360p Gen8

當我使用iLO連接並重新啟動SSH Daemon時,我沒有任何控制台提示,只有角落裡有一個灰色的小東西...

我經常需要重新啟動面臨此問題的伺服器。

我需要幫助來解決這個問題。我已經嘗試了一切。你曾經遇過類似的事情嗎?

答案1

對於ssh,看起來您正在使用putty密鑰,ssh不能使用putty密鑰,除非將其匯出為openssh格式。看起來該文件已被手動編輯,如果可能,請從備份中恢復私鑰,或者嘗試重新生成您使用的密鑰或創建一個新密鑰並比較兩者以確保您使用的密鑰沒有格式化更改了。

至於 telnet 立即結束,這是可以預料的,因為 ssh 正在尋找 ssh 連線而不是 telnet 連線。

一旦你解決了關鍵問題,你應該能夠通過 ssh 進入盒子。

至於mysql登錄,通常root的預設登入僅限於127.0.0.1和本機。因此,除非您允許某些主機 (yourhost.domain) 或 %(順便說一句,% 是個壞主意),否則您將無法連接,除非您使用 ssh 隧道以便可以在本地連接。另一件事是您目前的命令mysql -h db5 -uroot正在嘗試在沒有密碼的情況下連接到 root。嘗試一下mysql -h db5 -u root -p,它會提示您輸入密碼。

答案2

格魯澤,

這是我的一點看法。

  1. 檢查您的設定文件,確保您允許從您連接的網路存取裝置。

  2. 確保在這些伺服器及其所連接的網路上。他們可以 ping 您。如果您在網路中採用單向路由,那麼您的存取嘗試將會失敗。某些網路管理員會封鎖 ICMP Ping 要求,而防火牆/存取清單規則可能會阻止您存取設備,除非您與設備位於同一子網路中。

  3. 較新的 Linux 伺服器安裝的 iptables / ipforwarding / ipchains 預設會阻止所有內容。您必須手動開啟所需的每個連接埠或套接字。一些安裝腳本會處理這個問題。有些失敗,您必須使用手動 Linux 命令打開它們。

雙刃劍..被應用程式設定/本地電腦或您自己的網路團隊阻止。

希望這個對你有幫助。乾杯...

相關內容