Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using RHEL6 and I set up an sftp server through sshd. Here is the relevant sshd config:

Match Group sftpusers
  ChrootDirectory /sftp/%u
  ForceCommand internal-sftp
  X11Forwarding no
  AllowTcpForwarding no

I have a user sftpuser1 which is part of the group sftpusers and is assigned a home directory of /sftp/sftpuser1/home. However, when I login to sftp with this user, I get to /sftp/sftpuser1, and not the home directory.

How can I configure this user to be forced into the home directory upon connecting to the sftp server?

share|improve this question

Update this to:

ChrootDirectory /sftp/%u

To this (assuming all users with have /home/ off of this directory):

ChrootDirectory /sftp/%u/home
share|improve this answer
I already tried that. When I do, I can no longer login to the sftp server with that user. – blizz Jun 17 '14 at 0:32
What does your /var/log/auth.log say when it is configured that way? – David Rickman Jun 17 '14 at 0:36
Jun 17 06:04:09 Linux1 sshd[31694]: Accepted password for sftpuser from port 61030 ssh2 Jun 17 06:04:09 Linux1 sshd[31694]: pam_unix(sshd:session): session opened for user sftpuser by (uid=0) Jun 17 06:04:09 Linux1 sshd[31698]: fatal: bad ownership or modes for chroot directory "/sftp/sftpuser/home" Jun 17 06:04:09 Linux1 sshd[31694]: pam_unix(sshd:session): session closed for user sftpuser – blizz Jun 17 '14 at 0:40
You need to set root as the owner of the %u/home directory and create subfolders for them to access. If root doesn't own the main folder, then it won't permit them to logon. – David Rickman Jun 17 '14 at 0:42
right but im trying to avoid them seeing a subfolder....the "home" folder is the subfolder i want their session opened in – blizz Jun 17 '14 at 0:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.