原創Couldn't read packet: Connection reset by peer 錯誤排查思路(推薦)


作為一個運維 不是你懂多少知識才是你的價值 你有幸能遇到多少錯誤才是你的最大的價值

知識 你有我有大家有  錯誤我有你沒有 這便是我的價值

我遇到一個錯誤 蠻難遇到的一個錯誤 所以想分享給大家 

下面我在模擬機演示給大家 用 root權限 避免你們說是因為權限的錯誤

2017年9月5日 我在切換sftp時候遇到一個錯誤(端口號是22 說寫端口號的閉嘴)

[root@backup ssh]# sftp -oPort=22 root@10.0.0.31

Connecting to 10.0.0.31...

The authenticity of host '10.0.0.31 (10.0.0.31)' can't be established.

RSA key fingerprint is 25:4d:a6:65:1b:77:85:41:f0:18:07:c8:e0:12:c9:9b.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '10.0.0.31' (RSA) to the list of known hosts.

root@10.0.0.31's password:

subsystem request failed on channel 0

Couldn't read packet: Connection reset by peer

 

我們來看看這個錯誤 

Couldn't read packet: Connection reset by peer

 無法讀取數據包:通過對等項重置連接

這是一個很難遇到的錯誤

 

排查之路:

tail -f /var/log/messages

Sep  5 12:31:53 backup sshd[3131]: subsystem request for sftp failed, subsyst found

Sep  5 12:37:15 backup sshd[3136]: Accepted password for root from 10.0.0.31 9088 ssh2

Sep  5 12:37:15 backup sshd[3136]: subsystem request for sftp

Sep  5 12:37:15 backup sshd[3136]: subsystem request for sftp failed, subsyst found

 

 

[root@backup ssh]# rpm -ql openssh-clients

/etc/ssh/ssh_config

/usr/bin/.ssh.hmac

/usr/bin/scp

/usr/bin/sftp

/usr/bin/slogin

/usr/bin/ssh

/usr/bin/ssh-add

/usr/bin/ssh-agent

/usr/bin/ssh-copy-id

 

[root@backup ssh]# grep sftp /etc/ssh/sshd_config

Subsystem        sftp  /usr/libexec/openssh/sftp-server

[root@backup ssh]# ll /usr/libexec/openssh/sftp-server

-rwxr-xr-x. 1 root root 67640 Mar 22 16:33 /usr/libexec/openssh/sftp-server

 

查看文檔

 

 

If so, it's the cause of this error message. That's especially true if your sftp user is logging into a chrooted environment, where "/usr/lib" probably does not exist. My own sftp server is configured this way.

 

However, SSHD has the sftp functionality built-in and does not need to execute an external "helper" program like that. So, if you have a line like the above, it can be fixed by changing it to:

如果是,這是錯誤消息的原因。尤其是,如果您的sftp用戶登錄到一個chrooted環境,其中“/ usr /lib”可能不存在。我自己的sftp服務器是這樣配置的。

 

但是,sshd具有內置的sftp功能,不需要執行像這樣的外部“助手”程序。因此,如果您有類似上述的行,可以通過將其更改為:

 

 

 錯誤解決邏輯圖

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM