tags:

views:

3967

answers:

6

This is a idea for a security. Our employees shall have access to some commands on a linux server but not all. They shall e.g. have the possibility to access a log file (less logfile) or start different commands (shutdown.sh / run.sh).

Background information:

All employees access the server with the same user name: Our product runs with "normal" user permissions, no "installation" is needed. Just unzip it in your user dir and run it. We manage several servers where our application is "installed". On every machine there is a user johndoe. Our employees sometimes need access to the application on command line to access and check log files or to restart the application by hand. Only some people shall have full command line access.

We are using ppk authentication on the server.

It would be great if employee1 can only access the logfile and employee2 can also do X etc...

Solution: As a solution I'll use the command option as stated in the accepted answer. I'll make my own little shell script that will be the only file that can be executed for some employees. The script will offer several commands that can be executed, but no others. I'll use the following parameters in authorized_keys from as stated here:

command="/bin/myscript.sh",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty
ssh-dss AAAAB3....o9M9qz4xqGCqGXoJw= user@host

This is enough security for us. Thanks, community!

+3  A: 

What you are looking for is called Restricted Shell. Bash provides such a mode in which users can only execute commands present in their home directories (and they cannot move to other directories), which might be good enough for you.

I've found this thread to be very illustrative, if a bit dated.

Vinko Vrsalovic
What if the user does "!/bin/sh" or some such from the less prompt?
PEZ
Obviously, they can't. What part of "only execute commands present in their home directories" didn't you understand?
Ubersoldat
@Ubersoldat: Please grow up and tone down the aggression in all your posts. He was asking whether the restriction only applies to bash or child processes too (and to answer his question, it turns out it doesn't).
Ant P.
+2  A: 

Google is our friend. Among the first hits:

HTH

Zsolt Botykai
chroot and jail are nice tools. But for my problem I don't think it is a solution. I don't want to hide other directories than the home dir, I want to restrict the access to files _in_ the user home dir!
Marcel
+4  A: 

You can also restrict keys to permissible commands (in the authorized_keys file).

I.e. the user would not log in via ssh and then have a restricted set of commands but rather would only be allowed to execute those commands via ssh (e.g. "ssh somehost bin/showlogfile")

HD
That looks interesting. Is it possible to define multiple commands?
Marcel
This article gives you a few options for multiple commands using the authorized_keys file:http://www.linuxjournal.com/article/8257
Bash
@rd834...: Thanks a lot. I think this gave me a "good" solution... (added to question). I'll accept this answer as "correct".
Marcel
+1  A: 

You might want to look at setting up a jail. link text

tmeisenh
+2  A: 

You should acquire `rssh', the restricted shell

You can follow the restriction guides mentioned above, they're all rather self-explanatory, and simple to follow. Understand the terms `chroot jail', and how to effectively implement sshd/terminal configurations, and so on.

Being as most of your users access your terminals via sshd, you should also probably look into sshd_conifg, the SSH daemon configuration file, to apply certain restrictions via SSH. Be careful, however. Understand properly what you try to implement, for the ramifications of incorrect configurations are probably rather dire.

Chuah
A: 

Another way of looking at this is using POSIX ACLs, it needs to be supported by your file system, however you can have fine-grained tuning of all commands in linux the same way you have the same control on Windows (just without the nicer UI). link

Another thing to look into is PolicyKit.

You'll have to do quite a bit of googling to get everything working as this is definitely not a strength of Linux at the moment.

Redbeard 0x0A