Main Topics
Browse All TopicsHello,
I am trying to restrict user to their home directory when they login remotely through sftp. I have followed all the steps specified in following URL.
http://knol.google.com/k/d
But the user can still traverse through directory system. I have set root permissions to individual directories so he can not get that directory listing but he can see all the directories in /
Please help me to get rid of this problem. Its very urgent.
Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hello guys,
Thanks for your reply.
I am using openssh-4.3p2-4.12.fc5 version of openssh.
I have created a new user named 'sftpfred' using command $: useradd -s /bin/false -m -d /home/sftpfred -c "Fred SFTP" -g testadmin sftpfred
I have added that in chroot.conf file. Now when I tried to login through that user it was not letting me logged in.I have attached the files information as code snippet that may help you to resolve this.
Thanks Again!
I think that you can't create a user for sftp and give it a "false" shell. In my previous attempts to do that, I couldn't login either. The user must have a valid shell to log in even if it is not logging in to do interactive commands.
If you are concerned about security, you could use a "secure ssh" shell like this:
http://dragontoe.org/rssh/
Remember that the shell you use must be available inside the chroot jail, because if everything is configured correctly it's inside the jail that the system will look for the binary.
Hello ,
Is it required to use rssh.
have tried with two users. I have attached their setting in code snippet. Now I login through testadmin using sftp testadmin@localhost it let me login but I can traverse through directory system and when i login through sftpfred in shows me following error.
Request for subsystem 'sftp' failed on channel 0
Couldn't read packet: Connection reset by peer
This is strange. There is only one difference between these users that testadmin was created before establishment of jail.
Please let me know where I am doing wrong. I will be checking comments frequently as it is urgent.
Thanks!
You can see that the first user is not getting chrooted as the pam_chroot module is complaining that the user's home directory is writable by non-root. Just changing the permissions to deny writing by others than root should correct that.
For the second user, apparently there is a problem in the pam chain. The pam_env module isn't finding it's configuration file.
You can remove the pam_env of the chain just to test or find out why the module can't find it's configuration.
If you don't want a chroot jail, you can always just change the / folder's permissions to remove READ permission.
[Quick review of Directory Permissions in Linux]
Part 1 - understand that a directory is nothing but a table that points a name to an inode within a filesystem
Part 2 - To see the names (list them), you must have READ permission
Part 3 - To use the name to get an INODE value (and thus, access the file), you need EXECUTE permission
Part 4 - To add, remove, or change the name of a file in the directory, you need WRITE permission
[end review]
So, with the above in mind, it is SAFE to remove READ permission from / (and any other system folders)
BUT -- if you also remove execute permissions, your system will crash like an insurance commission car! (nothing but root processes will be able to open ANYTHING on your filesystem), so don't go overboard!
BTW: If you're a smart admin, you'll have yourself in some admins group -- you can safely "chgrp admins /" to make sure you (and any other admins) can still read (run ls on) the / directory!
Just my thoughts... I try not to overthink these things!
Dan
IT4SOHO
"Request for subsystem 'sftp' failed on channel 0
Couldn't read packet: Connection reset by peer"
This could be caused because there are not enough permissions to execute the sftp-server.
Look for the permissions of the sftp-server binary inside your chroot jail. Also have a look at the permissions of the directory that the sftp-server binary is contained in.
Hello,
As I am using rssh now. I am yet not able to connect through sftp at my server machine but yes i am able to do that at my local machine .Server machine show just "connection closed" error. I have also seen the log but there is no any error message.
I have attached two files first one for sftp as testuser with chrooting that generates error and second for sftp as root without chrooting.
Please let me know How can I troubleshoot this error.
Thanks!
OK, so the first user will be chrooted to your jail, while the root user is not. I think that there is something missing inside the jail.
As already mentioned, you have to have all the tools and libs necessary for the correct functionality of sftp / rssh inside the jail. There is no way that any file outside the jail will be accessed, so if anything is missing, the connection will fail.
Business Accounts
Answer for Membership
by: RBEIMSPosted on 2009-08-05 at 04:57:35ID: 25022333
Can you put an excerpt from your log file when a user logs on? Are you sure you added the user in the /etc/chroot.conf file?
I ask this because once you chrooted into a new directory, you have no means to go to the default system root and list directories or files. You are confined to the jail.
You would have to find what could be going wrong so that the users are not being chrooted as they should when they log in.