在 ubuntu 18.04 中配置 SFTP,錯誤“/bin/bash No such file or directory”或“Unexpected end of file from SFTP server”

在 ubuntu 18.04 中配置 SFTP,錯誤“/bin/bash No such file or directory”或“Unexpected end of file from SFTP server”

我按照本教學在 ubuntu 18.04 中設定 SFTP (https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-ubuntu-18-04)但是當我嘗試從 FileZilla 連接時,出現此錯誤“從 SFTP 伺服器接收到意外的文件結束” 當我嘗試從終端連接時,出現此錯誤“/bin/bash:沒有這樣的文件或目錄”

這是我的「sshd_config」:

Match User my-user
PasswordAuthentication yes
ChrootDirectory /var/www 
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no

如果我評論 #ChrootDirectory,一切都會像魅力一樣工作,...好吧,不像魅力,因為這樣我就可以訪問 ubuntu 中的每個文件,這出於安全原因並不好

“www”資料夾的檔案權限 drwxr-xr-x 4 根 根 4096 八月 27 11:57 www

“www/webapi”的檔案權限 drwxr-xr-x 2 檔案上傳 檔案上傳 4096 八月 29 09:00 webapi

這對我不起作用: SSH 失敗,/bin/bash:沒有這樣的檔案或目錄

知道我錯過了什麼嗎?謝謝 !

答案1

我找到了一個解決方案希望它對其他人有幫助

使用 sudo 權限開啟 sshd_config 檔案 sudo nano /etc/ssh/sshd_config

#Subsystem sftp /usr/lib/openssh/sftp-server <- comment this
Subsystem sftp internal-sftp   <- add this line

然後重新啟動: sudo systemctl restart vsftpd.service

相關內容