SFTP 連線問題

SFTP 連線問題

我剛剛設定了一個新的 debian sftp 伺服器,以便為多個 CHROOTed 使用者提供存取權限。雖然我添加的第一個帳戶工作正常,但第二個帳戶在身份驗證後立即斷開連接。

sftp -v 輸出:

debug1: Authentication succeeded (password).
Authenticated to xxx.xxx.xxx.xxx ([xxx.xxx.xxx.xxx]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Connection to xxx.xxx.xxx.xxx closed by remote host.
Transferred: sent 2416, received 1376 bytes, in 0.0 seconds
Bytes per second: sent 279797.8, received 159355.1
debug1: Exit status -1
Couldn't read packet: Connection reset by peer

和使用者的配置:

Match group joseph
        ChrootDirectory /backups/joseph
        x11Forwarding no
        AllowTcpForwarding no
        ForceCommand internal-sftp

CHROOTed 資料夾的 rw 權限為 a+rw,並且歸 root 所有。

有任何想法嗎?

PS - 我還應該添加“子系統 sftp 內部 sftp”。

答案1

看來我在創建以下用戶和群組時犯了一些錯誤這封信的指南。

實際上對我來說是如何工作的:

$useradd <user>
$usermod -d /<folder> -s /bin/false <user>
$chmod 744 /<folder>
  • 授予使用者對其自己的資料夾進行讀取/寫入的權限。
  • 允許使用 ssh/sfpt 協定進行連接
  • 在 /etc/ssh/sshd_config 中為每個使用者新增了以下內容:

匹配群組
ChrootDirectory /folder
x11Forwarding 否
AllowTcpForwarding 否
ForceCommand 內部-sftp

相關內容