Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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 at 0:32
    
What does your /var/log/auth.log say when it is configured that way? –  David Rickman Jun 17 at 0:36
    
Jun 17 06:04:09 Linux1 sshd[31694]: Accepted password for sftpuser from 192.168.1.235 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 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 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 at 0:47

Your Answer

 
discard

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.