Configuring SFTP in ubuntu 18.04, error "/bin/bash No such file or directory" or "Unexpected end-of-file from SFTP server"
I'm configuring SFTP in ubuntu 18.04 following this tutorial (https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-ubuntu-18-04) But when I try to connect from a FileZilla I get this error "Received unexpected end-of-file from SFTP server" And when I try to connect from terminal I get this error "/bin/bash: No such file or directory"
this is my "sshd_config":
Match User my-user
PasswordAuthentication yes
ChrootDirectory /var/www
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
If I comment #ChrootDirectory, everything works like a charm, ... well no like a charm because then I have access to every file in ubuntu, which is not good for security reasons
File permission for "www" folder drwxr-xr-x 4 root root 4096 Aug 27 11:57 www
File permission for "www/webapi" drwxr-xr-x 2 file-upload file-upload 4096 Aug 29 09:00 webapi
this is not working for me: SSH Fails, /bin/bash: No such file or directory
Any idea what am I missing ??? Thank you !!!
Solution 1:
I found a solution hope it helps someone else
open sshd_config file with sudo privileges sudo nano /etc/ssh/sshd_config
#Subsystem sftp /usr/lib/openssh/sftp-server <- comment this
Subsystem sftp internal-sftp <- add this line
Then apply a restart: sudo systemctl restart vsftpd.service