I've found a question with an answer here on Security StackExchange or on Unix StackExchange, but I can't find it anymore apparently :( If you find this answer already, help would be appreciated, I already searched both places extensively.

What I want to achieve is to have two different cloud providers and have the encryption key locally on my machine and have the file system of the other server mounted ENCRYPTED and for it to be secure. I know there's been an answer for this somewhere but I can't find it anymore. It contained something with mounting with encfs, cryfs or similar. The only requirements are for it to be secure and that the other server gets mounted with an encryption layer (encrypted on transit & encrypted at rest).

  • What would be the most secure method for this?

  • As an alternative: what would be the most secure method if one of the cloud servers is trusted and the other one is just used for encrypted-only storage? By that I mean only encrypted data goes in and comes out of the storage server.

I found a good sshfs guide here: https://unix.stackexchange.com/a/62682

But I need to somehow to combine it with cryfs, encfs or similar (the best option)

  • You might be looking for some combination of s3fs (to mount the cloud file storage in your local file system) + encfs (to add an encryption layer over the mounted file storage). See emcken.dk/work/linux/2010/12/01/…. This article is dated, but maybe it will point you in the right direction.
    – mti2935
    Sep 7, 2022 at 17:41
  • @mti2935 would switching out encfs with cryfs be a good solution? also I don't need s3fs I guess, since I'm not using S3, what should I use instead? sshfs + cryfs? Sep 7, 2022 at 17:48
  • Sorry, I don't know. It's been a while since I played with this.
    – mti2935
    Sep 7, 2022 at 18:02
  • " ...two different cloud providers ... my machine ... the other server" - I'm not fully sure about what you exactly refer to here. Do you mean that you have two servers, each with a different cloud provider and that "my machine" is one of these servers and "the other server" the other one (at the different provider)? And couldn't the question simplified to just asking on how to keep the encryption key for a file system remote and load it only from remote when mounting the file system? Sep 7, 2022 at 19:37
  • @SteffenUllrich sorry for the confusion. The main scenario would be two servers, which I don't trust and they have to have encryption to make up some trust. The second alternative scenario is that I trust one server or PC and I want to host my data on this remote server, which would probably be equal to encrypting files on Dropbox/GDrive/OneDrive etc. The key on the local machine is only decrypting and only in that case. If you find my question confusing feel free to edit accordingly. Sep 7, 2022 at 19:47

1 Answer 1


In short, you mount the remote server, and then an encryption layer in top of that (such as encfs or cryfs).

For example, using encfs:

mkdir /mnt/server-A
mkdir /mnt/server-A/insecure
mkdir /mnt/server-A/secure
sshfs serverA.example.com:/storage/folder /mnt/server-A/insecure
ENCFS6_CONFIG=/mnt/server-A/encfs6.xml encfs /mnt/server-A/insecure /mnt/server-A/secure
cp -v /home/SirMuffington/secret_file.txt /mnt/server-A/secure

encfs can be replaced with cryfs as a more modern alternative that fixes some of its shortcomings.

The folders are used this way:

/mnt/server-A/insecure provides the files in server-A, mounted locally. These are encrypted, so someone at server A would have no access to the underlying files, as they are encrypted by encfs/cryfs.

/mnt/server-A/secure provides the plaintext view of the files. They are actually saved (once encrypted) on /mnt/server-A/insecure which really is storing the files on folder /storage/folder of serverA.example.com.

/mnt/server-A/encfs6.xml Is a configuration file for encfs. It is usually stored on the encrypted folder, but here I am storing it outside.

And that's it. Your local computer is presumed to be trusted. Since all encryption takes place locally, there is quite little trust placed on the server (the are are some things it could do, most importantly, deleting all the files or reverting them to the state they were in some months ago).

Note that you don't need a second server, as you are not trusting the server to begin with.

  • Does this logic have any flaws? Like is it resistant to MitM and potentially malicious sysadmins on Server B? (if we were to use the two server scenario) Sep 8, 2022 at 15:23

You must log in to answer this question.

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