LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-22-2014, 01:09 PM   #1
amit.suthar
LQ Newbie
 
Registered: Apr 2014
Posts: 2

Rep: Reputation: Disabled
Restrict SSH user to multiple directory


Hello,

I am setting up a user who should have below configuratin.

Home dir = /home/test

Only allowed to view below directory

/var/log/tomcat
/usr/local/opus

He must not able to even real other directory. He should have access to only above directories.

Also he should be able to run all commands and allow to restart only apache and tomcat service. He should not able to restart any other service.

Please help me to set it up.
 
Old 04-22-2014, 01:40 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,693

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by amit.suthar View Post
Hello,
I am setting up a user who should have below configuratin.

Home dir = /home/test

Only allowed to view below directory

/var/log/tomcat
/usr/local/opus

He must not able to even real other directory. He should have access to only above directories.
Sorry, not possible. You can run SSH in a chroot jail, but that limits them to their OWN home directory. You can't have multiple directories specified. The only possibility would be to make symbolic links to those directories, but even then that's not a wise idea, since you'd then have a hard time with permissions for other users (like Apache, tomcat, etc.), being able to access them.
Quote:
Also he should be able to run all commands and allow to restart only apache and tomcat service. He should not able to restart any other service.
Please help me to set it up.
You can set up sudo to let users run certain commands as root. Restarting services is a root-only thing, and restricting a user to one or two commands is fairly simple. There is much documentation on setting up the sudoers file you can find with a Google search.
 
Old 04-22-2014, 01:45 PM   #3
amit.suthar
LQ Newbie
 
Registered: Apr 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hello,

Thanks for quick reply. I was also thinking that its not possible just want to know from experts that if its possible.

Can you provide me a link to easily setup chroot in centos ?
 
Old 04-22-2014, 02:20 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,693

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by amit.suthar View Post
Hello,
Thanks for quick reply. I was also thinking that its not possible just want to know from experts that if its possible. Can you provide me a link to easily setup chroot in centos ?
http://www.google.com

Put "how to setup ssh chroot in centos" into the search box, and press ENTER.
 
Old 04-28-2014, 05:33 AM   #5
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 354

Rep: Reputation: 51
You can "mount" other directories benieth jailed home, like:
# mount -o bind /var/log/tomcat /home/user/tomcatlogs
 
Old 04-28-2014, 06:28 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Your best bet would be to look into using SELinux to define a specific role.

But you have to realize that the types already assigned to the directories/files may require you to also grant access to other files and directories.

Second, partly a nit... If the user can only access /var/log/tomcat and /usr/local/opus, how is the user to use ANY commands, or even have a shell? These have to be accessed through /usr/bin... and depending on what the user is doing, may also require access to /tmp, /var (log files reporting other errors that may be related to failures in tomcat).
 
  


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 user to one directory only??? xanthaos Linux - Security 4 01-10-2010 06:14 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
chroot to restrict ssh directory access vbsaltydog Linux - Security 1 07-23-2006 04:28 PM
file transfer over ssh restrict directory browsing niall0s Linux - General 11 09-11-2003 02:50 PM

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

All times are GMT -5. The time now is 01:32 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