11

Is there an ability to not allow sudoers view your folder (only you and root can access folder)?

4
  • 1
    @depquid: Is it? I'm not sure what Ubuntu's default /etc/sudoers is, but you could just not add all users to the admin or sudo group. Jun 12, 2013 at 23:17
  • Yes my OS is Ubuntu. There are 2 standart users (in sudoers group) and 2 ftp (locked in their home folders). Jun 13, 2013 at 8:54
  • @KeithThompson Realizing I was mistaken, I deleted my comment. But then I realized it was mostly correct in the context of the OP. To clarify, Ubuntu doesn't use a root password by default, so root access is gained via sudo. And permission to use sudo is typically granted by making a user part of the admin group. And members of the admin group are allowed full root access (i.e. sudo su - is allowed). So "sudoers", in the OP's terms, are users with root access by default on Ubuntu.
    – depquid
    Jun 13, 2013 at 15:24
  • 1
    @ArthurHalma Don't forget that with a default umask of 022 (or less), files are created world-readable. Make sure your umask and/or permissions are set appropriately, otherwise all users will be able to read your files.
    – depquid
    Jun 13, 2013 at 15:32

5 Answers 5

14

Assuming that by “sudoers” you mean people who are allowed to run commands as root with the sudo prefix, because they are mentioned in the sudoers file through a line like bob ALL=(ALL) ALL, then these people are root. What defines being root isn't knowing the password of the root account, it's having access to the root account through whatever means.

You cannot protect your data from root. By definition, the root user can do everything. Permissions wouldn't help since root can change or bypass the permissions. Encryption woulnd't help since root can subvert the program doing the decryption.

If you don't trust someone, don't give them root access on a machine where you store your data. If you don't trust someone who has root access on a machine, don't store your data on it.

If a user needs root access for some specific purpose such as comfortably administering an application, installing packages, etc., then give them their own hardware, or give them their own virtual machine. Let them be root in the VM but not on the host.

5

Typically sudo access is granted in this type of manner:

# User privilege specification

root    ALL=(ALL) ALL
user1   ALL=(ALL) ALL

In this scenario, the user essentially has unfettered access to become root and do whatever they want. You can be more judicious in how you grant access to various tasks within sudo by doing things this way instead:

user1  ALL=(root) /usr/bin/find, /bin/rm

Here's we're limiting the commands that user1 can use to just find and rm. If you know that a user only needs a particular command you can grant them access exclusively to just that command.

Further more you can create scripts instead of just adding commands. For example:

user1  ALL=(root) /usr/local/bin/limited_script.sh

This script would be the only command they would have access to, you could for example cd /to/some/dir, in the script prior, and then wrap whatever command they need to have access to. This might be a way to limit their access.

Realize that the approach isn't full proof but would provide you some level of protection.

4
  • 4
    sudo /usr/bin/find . -maxdepth 0 -exec any-command-you-like \; Jun 12, 2013 at 23:19
  • Thanks, yes this is by no means a perfect solution, as in security it's about layers. But in this case it's a very thin layer.
    – slm
    Jun 13, 2013 at 0:23
  • Nice solution. But I think @Gilles answer is true. I will never feal in secure if someone else have even only some root priviligues. Jun 13, 2013 at 8:41
  • We said essentially the same thing. My answer provided you a method that would give you the ability to allow a user to run a command w/o accessing the disk, while his did not. I believe that was what your question was asking for? Additionally his answer speaks only to bob ALL=(ALL) ALL which is the worst way to delve out sudo permissions. As I said it's essentially impossible to block a driven user into not co-opting commands in sudo for nefarious purposes. But my answer is in fact more representative of how you'd give sudo permissions.
    – slm
    Jun 13, 2013 at 8:50
4

Unless the commands a sudoer can run are restricted in the sudoers config file (normally /etc/sudoers), sudo gives root, so there's nothing you can do to prevent a sudoer from accessing your directory.

4

Usually sudo is used to gain root-powers by normal users, at least of a particular command. So if root can read it, then a user using sudo can too.

I guess the best you could do was to encrypt the folder/files in some way to a personal password.

2

You might possibly use ACLs and in setting the appropriate ACE entries you might be able to do this. However, its a bit more hassle.

Anyway, if you do this, how is an administrator going to help you fix a problem with your files/directories? Either you trust your trusted users or you do not and move along to another system where you trust your administrators.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .