0

I am developing an in-house file-sharing system like Google Drive/Dropbox with very restricted shell access to users' own folder. The users have to be able to use mv ssh ls cd commands to access and navigate their own folders, also some users would be able to run gcc to compile their own program (But they are not allowed to run the programs they compiled). The only problem is I don't want people roaming around in system files or modifying system settings/variables.

First I thought maybe using containers/BSD Jails might be the solution but given that this system might have over 300 users, It adds unnecessary complexity and overhead.

What solutions are there on the open wild Internet? Thanks!

5
  • If your only goal is to prevent users from modifying the system - don't give 'em root.
    – Panki
    Jul 1, 2020 at 11:41
  • @Panki but even if I don't give them root, they can still modify system settings and could cause some damage.
    – user396583
    Jul 1, 2020 at 11:43
  • 1
    Do you have an example of that?
    – Panki
    Jul 1, 2020 at 11:44
  • @Panki So just simply not giving users root prevent damage to the system?
    – user396583
    Jul 1, 2020 at 11:49
  • 1
    Depends what you mean by damage and what you mean by system. Users could still fill up disks use up all RAM/CPU/net resources if you don't put some limits. They could use your system as a botnet C&C server and do a lot of illegal stuff without compromising the integrity of the system. Jul 1, 2020 at 12:18

1 Answer 1

1

First, let me say, whatever you do in this area is subject to users finding creative ways to get around what you've put in place.

Bash provides the concept of a "restricted shell" that will prevent users from using cd and limit them only to the commands that pre-exist in their path. You could create a directory that contains symbolic links to the set of "allowed" commands, and configure the user's path to point to that directory:

https://www.gnu.org/software/bash/manual/html_node/The-Restricted-Shell.html

$ PATH=/tmp/ex rbash
$ ls
src
$ cd /
rbash: cd: restricted
$ export PATH=/usr/bin:$PATH
rbash: PATH: readonly variable
$

Note, however, that if you put a command in the path that can exec arbitrary commands, this won't help:

$ rbash
$ cd /tmp
rbash: cd: restricted
$ vim
:!/bin/bash
$ cd /tmp
$

Even the documentation for Bash's restricted shell says:

Modern systems provide more secure ways to implement a restricted environment, such as jails, zones, or containers.

6
  • My only concern with containers etc. Is that once user count increases over let's say 300, it would affect system performance. Correct me if I am wrong.
    – user396583
    Jul 1, 2020 at 12:43
  • Compared to a let's say /bin/bash, a containers use more resources, at least that's what I know.
    – user396583
    Jul 1, 2020 at 12:45
  • @fedqx what you know is not true Jul 1, 2020 at 12:46
  • If you're using something like Docker, Docker can start to choke when you get hundreds of Docker containers, but that's a Docker limitation, not a technology limitation. You don't have to use Docker. Jul 1, 2020 at 12:47
  • Yes that's what I suspected, that's why I added"correct me if I am wrong" at the end of my comment.
    – user396583
    Jul 1, 2020 at 12:47

You must log in to answer this question.