1

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.

sftpUser1:x:1001:1001::/var/www/userFolder:/bin/false

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

1 Answer 1

3

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.

0

Not the answer you're looking for? Browse other questions tagged .