0

Is there a way to store a file on a disk as a user so that even the root user has no access to it?

I tried EncFS but that is no solution because the root user can switch to every user, so he/she can read the encrypted files too.

How can I store a file on the server so no-one can read it but me?

Maybe somehow store it spread it redundant accross the unused diskspace and keep the inodes in mind to recover it via checksums?

AviD
  • 72,708
  • 22
  • 137
  • 218
rubo77
  • 2,370
  • 10
  • 26
  • 49

2 Answers2

6

Ye cannot defeat root !

The root user can have complete control of the machine. The best that you can hope for is encryption: use GnuPG to encrypt the data with a sufficiently strong random password, that, of course, you won't reveal to the root user.

However, as soon as you decrypt the file on the machine, wherever you put it, root will be able to see it. Similarly, root has all the required power to plant a keylogger (and thus grab your password) or modify the gpg binary so as to recover a copy of your precious data as soon as you encrypt or decrypt it. The best you can hope for is the following:

  • You may hope to "fly under the radar" by making your file inconspicuous, not to be detected through some massive scans that the administrator runs regularly. This requires that you delete the decrypted file as soon as possible; this assumes that root activity is indeed a nightly scan or something like that.

    On a general basis, this concept is known as steganography.

  • You could encrypt and decrypt the file elsewhere, e.g. on your own laptop computer, using the machine-with-hostile-root only as storage space. That way, the root will only ever see the encrypted data, and not know the contents.

Tom Leek
  • 170,038
  • 29
  • 342
  • 480
0

It is not possible to prevent a root or administrator user from accessing a file under control of the OS. Your suggestion of obscuring the file might prevent someone from piecing it together in a meaningful way, but isn't really securing the file. Your thought to use an encrypted filesystem simply encrypts the files on disk such that only users with access to the system can read the files (and those users would be you and root). If someone were to steal a hard drive with an encrypted file system they might have a difficult time extracting data, but that doesn't prevent root from accessing the files. All you need to do is encrypt the file in such a way that only you know the decryption key.

TTT
  • 9,132
  • 4
  • 19
  • 32