User can't SFTP after chroot
- by Dauntless
Ubuntu 10.04.4 LTS
I'm trying to chroot the user 'sam'. According to all the tutorials out there this should work, but apparently I'm still doing something wrong.
The user:
sam:x:1005:1006::/home/sam:/bin/false
I changed /etc/ssh/sshd_config like this (at the bottom of the file):
#Subsystem sftp /usr/lib/openssh/sftp-server
# CHROOT JAIL
Subsystem sftp internal-sftp
Match group users
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
I added sam to the users group:
$groups sam
sam : sam users
I changed the permissions for sam's home folder:
$ ls -la /home/sam
drwxr-xr-x 11 root root 4096 Sep 23 16:12 .
drwxr-xr-x 8 root root 4096 Sep 22 16:29 ..
drwxr-xr-x 2 sam users 4096 Sep 23 16:10 awstats
drwxr-xr-x 3 sam users 4096 Sep 23 16:10 etc
...
drwxr-xr-x 2 sam users 4096 Sep 23 16:10 homes
drwxr-x--- 3 sam users 4096 Sep 23 16:10 public_html
I restarted ssh and now sam can't log in with SFTP. The session is created, but also closed immediately:
Sep 24 12:55:15 ... sshd[9917]: Accepted password for sam from ...
Sep 24 12:55:15 ... sshd[9917]: pam_unix(sshd:session): session opened for user sam by (uid=0)
Sep 24 12:55:16 ... sshd[9928]: subsystem request for sftp
Sep 24 12:55:17 ... sshd[9917]: pam_unix(sshd:session): session closed for user sam
Cyberduck says Unexpected end of sftp stream. and other clients give similar errors.
What did I forget / what is going wrong?
Thanks!