Sshd

將使用者覆蓋添加到 sshd_config 會導致 ssh_exchange_identification 錯誤

  • July 14, 2015

我想允許特定使用者進行 SSH TCP 轉發,所以我在 sshd_config 中添加了這一部分:

Match User rainmannoodles
   AllowTcpForwarding yes
   TCPKeepAlive yes

更改後,我在連接時收到以下消息:

ssh_exchange_identification: Connection closed by remote host

如果我註釋掉 Match User 塊,一切正常。該塊是文件中的最後一個塊。

我想不出這種行為的任何原因。這裡到底發生了什麼?這是完整的-vvv輸出:

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: identity file /Users/rainmannoodles/.ssh/id_rsa type -1
debug1: identity file /Users/rainmannoodles/.ssh/id_rsa-cert type -1
debug1: identity file /Users/rainmannoodles/.ssh/id_dsa type -1
debug1: identity file /Users/rainmannoodles/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
ssh_exchange_identification: Connection closed by remote host

檢查伺服器上的日誌,看看出了什麼問題。

我希望 sshd 抱怨您的配置文件格式不正確。該選項TCPKeepAlive不能在Match塊中使用,可能是因為 sshd 不支持在身份驗證完成後更改選項的值(此選項從連接開始使用,在Match條件可以測試之前)。

引用自:https://unix.stackexchange.com/questions/215554