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?

  • 1
    Encrypt it with a private key? PGP? – schroeder Jul 8 '14 at 20:31

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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.