Chroot users in Fedora 9, no ssh, sftp, Jail
Lets say you have a developer that needs to work on one of the sites that you are hosting on your web server in your basement and you don’t want them to have free range to everything on the box. Another piece of this is you really don’t want the user to have SSH access either. Sounds like a simple idea and really it is, but when you are new to Linux/Fedora this can be a little tricky. Im hoping that this will help some people trying to get this to work on their web servers and being able to jail users into a specific directory.
I did get some great information from:
http://www.minstrel.org.uk/papers/sftp/builtin/
This was almost enough to get me through the whole thing.
So where is what I did:
- Go to the end of this file emacs /etc/ssh/sshd_config and add:
# override default of no subsystems
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp# Example of overriding settings on a per-user basis
Match Group sftponly
X11Forwarding no
AllowTcpForwarding no
ChrootDirectory %h
ForceCommand internal-sftp - Restart ssh: /etc/init.d/ssh restart
- Create your user: useradd -d /path/to/chroot/dir username
- Remove SSH Access: usermod -s /bin/false username
- Set your the user to sftponly group: usermod -g sftponly -G sftponly username
- KEY: Make sure the path to your chroot is set to: chown root:root /var/userdir
That means /var and /var/userdir need to be root:root
MAJOR KEY: Make sure you also chmod 700 to those directories also!!
Hope this helps some people out.

March 6th, 2010 at 2:56 am
Thanks for this post, answers a bunch of questions I was having.
August 28th, 2010 at 1:37 am
[...] hope that helps! Thanks to UPWebdesign.com for giving me a jump start! This entry was posted in Programming. Bookmark the permalink. [...]
January 19th, 2011 at 2:27 pm
I am very thankful to this topic because it really gives useful information :;: