LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-06-2010, 03:48 AM   #1
xanthaos
LQ Newbie
 
Registered: Jan 2010
Posts: 7

Rep: Reputation: 1
Restrict user to one directory only???


Here's the beginning of the issue: I'm running Fedora 12 with httpd and sshd. I want to create a user with a scponly shell for sftp access, but this user should ONLY be able to view /the/http/base/dir and its subdirectories. The user should not be able to see or get into directories above the httpd base. Someone mentioned creating a chroot jail for sshd and binding the httpd base to that dir, but this seems like more work than is necessary for the application I wish. Also mentioned was creating a user, say user1 with a selinux user setting of staff_r. I have read the articles and creating a user of staff_r isn't overly difficult, but how would I make it where staff_r would be restricted to where I want them to be? If I'm not mistaken, that would require changing the context of /the/httpd/base/dir?

There doesn't seem to be a simple solution for this, but there is a solution somewhere I'm certain of it. Any help on this subject would be welcome.
 
Old 01-06-2010, 08:48 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by xanthaos View Post
Here's the beginning of the issue: I'm running Fedora 12 with httpd and sshd. I want to create a user with a scponly shell for sftp access, but this user should ONLY be able to view /the/http/base/dir and its subdirectories. The user should not be able to see or get into directories above the httpd base. Someone mentioned creating a chroot jail for sshd and binding the httpd base to that dir, but this seems like more work than is necessary for the application I wish. Also mentioned was creating a user, say user1 with a selinux user setting of staff_r. I have read the articles and creating a user of staff_r isn't overly difficult, but how would I make it where staff_r would be restricted to where I want them to be? If I'm not mistaken, that would require changing the context of /the/httpd/base/dir?

There doesn't seem to be a simple solution for this, but there is a solution somewhere I'm certain of it. Any help on this subject would be welcome.
Well, restricting a user to ONE directory only, a chroot jail is the only way to go. You can kludge something together, but it's not going to work as effectively, and leave lots of holes to exploit.
 
Old 01-07-2010, 03:17 AM   #3
xanthaos
LQ Newbie
 
Registered: Jan 2010
Posts: 7

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by TB0ne View Post
Well, restricting a user to ONE directory only, a chroot jail is the only way to go. You can kludge something together, but it's not going to work as effectively, and leave lots of holes to exploit.
I may setup a chroot jail in the end, but there's going to be a lot entailed in that. As the directory that needs access granted is part of the main server, I'll have to establish a chroot jail and bind that directory to it or establish a symlink to it.

Currently I have established a user with guest_u selinux context privs, reduced this person's privs to near nothing, and only given permission to one spot, the intended directory. So far the user can only login to their home directory or the target directory. If they try to use any other directory as their base or target SftpDrive reports a failed authentication. It's not a perfect solution, but it is a good layer solution, using the chroot can enhance this. This on top of no-pty in the keyfile and scponly as the shell should give me the results I need.

Keep the ideas coming, it's still a work in progress. Thanks much for the idea so far...
 
Old 01-08-2010, 01:24 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
The OpenSSH on Fedora 12 is new enough that it comes with the built-in chroot feature for sftp.

See the sshd_config(5) manpages -- especially the "ChrootDirectory" section.
 
Old 01-10-2010, 06:14 AM   #5
hapylestat
LQ Newbie
 
Registered: Jan 2010
Posts: 5

Rep: Reputation: 0
Quote:
Originally Posted by anomie View Post
The OpenSSH on Fedora 12 is new enough that it comes with the built-in chroot feature for sftp.

See the sshd_config(5) manpages -- especially the "ChrootDirectory" section.
or in the profile /home/username login script add chroot command
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict Samba user to particular directory Avadhut Linux - Newbie 2 04-07-2009 05:55 AM
restrict a FTP user from changing directory qrshat Solaris / OpenSolaris 5 02-11-2009 04:02 AM
how to restrict user for just one directory? J0sep Linux - Security 5 12-02-2008 04:49 PM
Restrict the user working directory ust Linux - Newbie 3 10-30-2008 11:42 PM
restrict user to home directory at logon pragti Linux - Security 6 02-27-2004 08:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration