Ssh – sftp chroot access via SSH

chrootssh

I have this setup in sshd_config:

AllowUsers test1 test2

Match group sftpgroup
         ChrootDirectory /var/www
         X11Forwarding no
         AllowTcpForwarding no
         ForceCommand internal-sftp

Match user test2
         ChrootDirectory /var/www/somedomain.dk
         X11Forwarding no
         AllowTcpForwarding no
         ForceCommand internal-sftp

I am trying to restrict test2 to only use /var/www/somedomain.dk

For some reason when I try to login e.g. with Filezilla on account test2 I get this error: "Server unexpectedly closed network connection"

The users are created and works. the SSH service has been stopped and started. test1 works when using e.g. filezilla and the root of the connection is /var/www. What am I doing wrong?

Best Answer

If the answer Cudos supplied does not help you, and I dont think it will (no offense), try this:

chown root:root /your/chroot/home
chmod 700 /your/chroot/home
chown user:sftpgroup /your/chroot/home/userdir
chmod 755 /your/chroot/home/userdir

remember: your users wont be able to write in their "root", you need to create a directory for them to use.

Related Topic