I use openssh-server for SFTP. I have a user called sftpuser which belongs to the group sftp and has its home directory in /home/sftpuser. Now I want to move this users home directory to another harddrive so I go into user settings and change the home directory to /media/disk/mystuff and make the folder /home/disk/mystuff belong to root, just like /home/sftpuser did. The problem is that when I change the home directory I can't log in anymore, I get the error message:

Read from remote host localhost: Connection reset by peer
Couldn't read packet: Connection reset by peer

Everything works as long as the home directory is the original home directory, but when I change that it stops working. I'm not changing anything else, sftpuser still belongs to the same group and the new home directory folder has the same permissions as the previous one.


Here's the relevant entries from /etc/ssh/sshd_config

AllowGroups sftp
Subsystem sftp internal-sftp
UsePAM yes
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no


Now to the questions. Where do you think the problem lies? Could it be that "ChrootDirectory %h" is hardcoded to lead to /home/*username* and it doesn't get the new home directory I've specified in user settings?

Is the best solution when wanting to share a folder via SFTP to make that directory the home folder of that user and create a new user for every other folder you want to share? I can't think of any other way and symbolic links don't work (which makes sense considering ChrootDirectory).