SSH 連線:ssh_exchange_identifcation

SSH 連線:ssh_exchange_identifcation

我已經透過 Mac 連接到遠端伺服器大約一個月了。截至最近,我嘗試使用 ssh dylan@MY_IP 進行連線並收到此訊息。

ssh_exchange_identification: read: Connection reset by peer

我還得到了一些診斷資訊...

debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to {MY IP{ [MY IP] port 22.
debug1: Connection established.
debug1: identity file /Users/watson/.ssh/id_rsa type -1
debug1: identity file /Users/watson/.ssh/id_rsa-cert type -1
debug3: Incorrect RSA1 identifier
debug3: Could not load "/Users/watson/.ssh/id_dsa" as a RSA1 public key
debug1: identity file /Users/watson/.ssh/id_dsa type 2
debug1: identity file /Users/watson/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2

經過一些研究後,我嘗試了以下...

  1. 重新啟動了我的路由器
  2. 清除了我的“known_hosts”文件
  3. 刪除了我的“known_hosts”文件
  4. 釋放並更新我的 DHCP
  5. 我還嘗試在另一個裝置(Windows)上使用 Putty,但也出現錯誤

請注意,我沒有對伺服器進行任何更改來禁止此通訊。

另外,我不確定這是否會導致問題,但我已透過它的網域和 IP 連接到它。

此外,我能夠從另一個 IP 位址成功連線。

我知道這是一個大問題,有很多資源,但很多解決方案都不起作用,我也沒有真正看到任何類型的解決方案。

更新

我強制它使用協議 1。運行它並顯示調試資訊:

debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to MY_IP [MY_IP] port 22.
debug1: Connection established.
debug1: identity file /Users/watson/.ssh/identity type -1
debug1: identity file /Users/watson/.ssh/identity-cert type -1
ssh_exchange_identification: Connection closed by remote host

答案1

這就是我在連接到 SSH 伺服器時解決“ssh_exchange_identification:連接被遠端主機關閉”錯誤的方法。

將軟體包解壓縮到 root 後嘗試連接到嵌入式 Linux 電腦時出現此錯誤。許多庫檔案被替換,包括 libssl。

嘗試連線:

chetic@ubuntu:~$ ssh -v [email protected]
OpenSSH_6.2p2 Ubuntu-6ubuntu0.3, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to SC [192.168.1.100] port 22.
debug1: Connection established.
debug1: identity file /home/delaval/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/delaval/.ssh/id_rsa-cert type -1
debug1: identity file /home/delaval/.ssh/id_dsa type -1
debug1: identity file /home/delaval/.ssh/id_dsa-cert type -1
debug1: identity file /home/delaval/.ssh/id_ecdsa type -1
debug1: identity file /home/delaval/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2p2 Ubuntu-6ubuntu0.3
ssh_exchange_identification: read: Connection reset by peer

谷歌搜尋似乎只建議檢查hosts.deny和hosts.allow,但我的目標機器沒有這樣的檔案。

重新啟動後(按照 Karthik 的建議),sshd 未運作。我嘗試在目標上手動啟動 sshd:

# sshd
OpenSSL version mismatch. Built against 1000002f, you have 1000105f

我用原始版本取代了 /usr/lib/libssl.a 並啟動了 sshd,一切恢復正常。就我而言,問題是由我最初解壓縮到 root 的套件中的版本不正確引起的。

答案2

我遇到了同樣的錯誤(但是來自任何機器,包括通過 的麻煩機器ssh localhost)。

當我遷移用戶設定檔時,它就開始了;即以 root 身分複製檔案後,然後執行以下命令chown -R username /Users/username/Destop

無論如何,完全不確定為什麼 /var/empty 所有者被更改為用戶名,但ssh肯定需要/var/empty由 root 擁有(否則你會得到ssh_exchange_identification: read: Connection reset by peer):

    sudo chown root /var/empty

答案3

這不是您本機的問題,而是伺服器端的問題。可能有多重因素導致這個問題:

  1. 遠端伺服器上 /etc/hosts.allow 或 /etc/hosts.deny 配置的變更。
  2. 伺服器負載重。

過去,當我遇到這些問題時,我按照以下順序做了兩件事之一:

  1. 按照上面文章中引用的方式修改 /etc/hosts.allow。 (並重新啟動SSH伺服器)
  2. 如果 /etc/hosts.allow 已經符合要求,只需重新啟動 SSH 伺服器(執行此操作時要小心!)
  3. 如果重新啟動不起作用,請重新產生伺服器金鑰並重新啟動 SSH 伺服器(這是有風險的,因為登入這台電腦的每個使用者都會收到有關伺服器金鑰已變更的錯誤)

通常情況下,1解決了問題,但在某些情況下我不得不做2..我一直無法弄清楚為什麼情況確實如此,只是它已經起作用了。也許它與密鑰的呈現方式有關,或者它可能以某種方式被損壞 - 我不確定。但我所知道的是,該錯誤完全與伺服器以及設定 SSH 連線時握手的方式有關。

答案4

這肯定是一個錯誤,ssh 可以在我的一台機器上運行,但不能在另一台機器上運行。我解決了,按照這些。

  1. 產生永不過期的存取令牌,然後選擇所有可用選項。
  2. 刪除現有的 SSH 金鑰。
  3. 使用 https 而不是 ssh 克隆儲存庫。
  4. 使用使用者名,但使用產生的存取令牌而不是密碼。

在此輸入影像描述

或者,您可以在現有儲存庫中使用此命令將遠端設定為 http,並使用此命令 git remote set-url originhttps://gitlab.com/[使用者名稱]/[儲存庫名稱].git

相關內容