On my Apache server I need to create new user accounts that would only access a specific folder, but when I try to change their root directory in ssh the server refuses to do it. I first tried to edit the sshd_config file to change the root directory of every accounts automatically, and when I saw that it was not working I tried to change it using usermod, here is the result:

>sudo usermod -R /var/www/userFolder sftpUser1
usermod: user 'sftpUser1' does not exist

but sftpUser1 really exists, here is the line in the passwd file, and the same line with the -d command to change the home directory executes well.


Here is what I added in sshd_config

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

Here is what appears in the Auth.log file after I tried to connect with the user

pam_unix(sshd:session): session opened for user sftpUser1 by (uid=0)
fatal: bad ownership or modes for chroot directory component "/"

The user belongs to the sftpusers group

closed as off-topic by Jakuje, GAD3R, countermode, Archemar, Eric Renouf Jan 5 '17 at 14:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jakuje, GAD3R, countermode, Archemar, Eric Renouf
If this question can be reworded to fit the rules in the help center, please edit the question.


The '-R' usermod option does not change the root dir for a user, it changes the root dir usermod operates inside of, so you can use it to modify users inside chroot environments.

Edit: I assume what you want to do is have the user placed inside a chroot environment when he logs in over SSH, you can use the 'ChrootDirectory' sshd_config option to do that.

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