How to jail linux user
Asked Answered
M

6

6

Is there something similar to chroot, but for users?

We are about to grant access to our servers for a client and would like them to see only the directories we allow.

Mandola answered 7/5, 2009 at 7:3 Comment(3)
Isn't that what permissions were designed for?Limeade
I want to go a bit further than just denying read / write access.Lottielotto
chroot only denies read/write access.Limeade
T
7

A Google search on "openssh jail" led me to SSHjail for openSSH. If your client uses ssh/scp to access the said servers, this might be what you are looking for.

Tinsmith answered 7/5, 2009 at 7:11 Comment(0)
A
5

The "best answer" from 2009 is outdated. OpenSSH now comes with the ChrootDirectory option. See http://www.debian-administration.org/articles/590 which is for an already-old version of ssh.

Ambulacrum answered 18/6, 2011 at 15:40 Comment(0)
J
4

It is important to note that chroot(2) is not meant for security purposes. It is incredibly easy to escape a chroot jail. See this article on abusing chroot for more information.

Janetjaneta answered 7/5, 2009 at 17:10 Comment(2)
This should be a comment, not an answer.Acanthocephalan
Comment non-answer, link-only and link already dead (server down).Convulsant
L
1

If you really want to go to that extreme, SE Linux (or any other mandatory access control) is a definite improvement of the default unix permissions.

Limeade answered 7/5, 2009 at 7:9 Comment(0)
S
1

An effective way to do this is to use lshell

Seiter answered 26/10, 2013 at 9:50 Comment(0)
K
0

No easy way to jail users in their homedirs. BTW, I would NEVER give access to my systems to someone I don't trust a minimum.

Last time I did, I used an "unescapable" menu based on http://bash.cyberciti.biz/guide/A_menu_box The .bashrc launches this script you would not escape :

~/.bashrc :
(LAST LINE)
./menu.sh; exit 0

Yes, I had to write scripts for each and every menu item (get logs, check sys, ...) but nobody to run 'chown -R root:root /' instead of *. Priceless.

[EDIT] : create a dedicated user, don't do this as root !!!

Karolkarola answered 7/8, 2014 at 11:46 Comment(1)
As mentioned in https://mcmap.net/q/439581/-how-to-limit-user-commands-in-linux-closed a "user could simply script sending a bunch of ^Z or ^C characters to the client right after entering the password to completely abridge any efforts made in the bashrc". lshell seems like the best solution from my reading so far...Laterite

© 2022 - 2024 — McMap. All rights reserved.