Ssh

密碼正確後sftp連接關閉

  • August 24, 2021

我在 debian 上使用 openssh-server 在埠 10022 上執行 sftp 伺服器,託管在 EC2/AWS 上。我為單個使用者配置了基於密碼的身份驗證,但在我送出正確的密碼後伺服器連接立即關閉。這是 sftp 客戶端的輸出:

steve@localhost's password: 
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
Authenticated to localhost ([127.0.0.1]:10022).
debug2: fd 4 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Connection to localhost closed by remote host.
Transferred: sent 1972, received 1644 bytes, in 0.0 seconds
Bytes per second: sent 1281358.2, received 1068231.7
debug1: Exit status -1
Couldn't read packet: Connection reset by peer

我的伺服器在 docker 容器中執行,真正奇怪的是,如果我在 Mac 上本地執行 docker 容器,我可以正常連接,但是當我在 AWS 伺服器上執行它時,我遇到了上述問題。上面的輸出是通過在 AWS 伺服器上執行 sftp 客戶端(嘗試連接到 localhost)產生的,所以我認為這與對 AWS 的網路訪問沒有任何關係

我會設置然後重新啟動 sshd 並檢查LogLevel VERBOSE以獲取更多詳細資訊。/etc/ssh/sshd_config``/var/log/auth.log

引用自:https://serverfault.com/questions/889430