I am trying to setup a sftp account to a specific folder. I have created a group ftpaccess and user testuser with home directory as seen here:
sudo addgroup ftpaccess
sudo useradd -d /home/forge/mydomain.com/downloads -m testuser -g ftpaccess -s /bin/false
sudo passwd testuser
sudo chown root:root /home/forge/mydomain.com/downloads
sudo chmod 755 /home/forge/mydomain.com/downloads
Then I have created an transfers directory inside testuser home folder:
sudo mkdir /home/forge/mydomain.com/downloads/transfers
sudo chown testuser:ftpaccess /home/forge/mydomain.com/downloads/transfers
Then I have setup sshd_config like this (rules added to the end of file):
# SFTP account
Subsystem sftp internal-sftp
Match group ftpaccess
ChrootDirectory %h
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
PasswordAuthentication yes
Now trying to sftp with this user sftp testuser@localhost but I get error:
packet_write_wait: Connection to 127.0.0.1 port 22: Broken pipe
Couldn't read packet: Connection reset by peer
What am I doing wrong?