Self-Hosting: You Still Rent the Machine, and Three Commands Need Fixing

About This Lesson

Self-hosting is the most practical subject in Module 9, and the good guides to it are ones a reader can actually follow. A typical setup is Nextcloud for files and Vaultwarden for passwords, on either a rented virtual private server (VPS) or hardware at home. The better guides walk through a deployment that works, compare hosting options fairly, give a hardening list that is real hardening rather than a gesture, and insist that an untested backup is not a backup. That last point is the single most valuable sentence in this module. Choosing Vaultwarden over the official Bitwarden server is correct. Telling people the time cost up front, rather than after they are committed, is unusual and good.

This lesson adds four things.

The central claim of self-hosting does not survive the architecture usually recommended. Guides list “no provider access, ever” as the first benefit and then recommend a rented virtual machine. On a rented machine the host can read the disk and snapshot the memory that holds your keys. The same guides usually admit this themselves, a few pages later, under the drawbacks.

Several commonly given commands do not do what guides say, and one of them produces a backup that is not restorable.

The largest available hardening measure is usually absent, and it is simpler than the reverse proxy most guides already walk you through.

And the software in these guides carries its own worked example of why one common configuration pattern is dangerous.

Learning Objectives

After you read this lesson, you can do these tasks:

  • State accurately what a rented virtual machine changes about who you trust.
  • Choose between rented and physical hardware based on what the data needs rather than on cost.
  • Avoid putting credentials into shell history, environment variables and compose files.
  • Say what Nextcloud’s server-side encryption does and does not protect, from its own documentation.
  • Write a snap-aware backup that actually captures the database, and verify it by restoring.
  • Remove the public attack surface entirely, and state the costs of doing so.

Prerequisites

  • Lesson 9.2, whose verifiability argument and metadata finding both apply here.
  • Lesson 8.2, on building so the wrong outcome is unavailable.
  • Basic Linux command line.

1. You Still Rent the Machine

Figure 1. The claimed benefits, tested against a rented virtual machine.

A typical list of self-hosting benefits opens with “complete control, no third party” and includes “no provider access, ever.”

The same guides then list, under the drawbacks of a VPS: the provider has physical access to the server.

Only the second statement is right.

On a rented virtual machine your service runs on somebody else’s hypervisor. The host can read the disk image, and can snapshot the running machine’s memory, which contains your encryption keys for as long as the service is running. Neither action requires your cooperation, and neither leaves a trace you would see. This is not a claim about any particular hosting company behaving badly. It is what renting a virtual machine is.

The comparison worth making

Set the two options side by side for the data people most often self-host for: restricted material, source protection and client engagements.

  • A zero-knowledge provider holds ciphertext and does not hold the key. If compelled, it produces ciphertext.
  • Your rented machine holds a running system with the key in memory, operated by a company that never promised not to look, that is not selling a privacy product, and whose terms of service say nothing resembling what a privacy provider’s say.

For the most sensitive data, the rented machine is the weaker position, and it is often the configuration recommended for exactly that data. Privacy ladders usually put self-hosting at the top, and for a VPS that ordering is wrong.

Two fixes

Split by what the data needs. Put the material you self-host because you distrust providers on hardware you physically hold. Use the rented machine for the things where availability, bandwidth and a static address matter more than provider opacity. Home hardware against a VPS is usually presented as a cost and convenience trade-off. It is also a trust trade-off, and that is the more important axis.

Or encrypt before it reaches your own server too. Run the client-side layer from Lesson 9.2 over your own Nextcloud. It costs nothing, it closes the hypervisor hole, and it means the thing on the rented disk is ciphertext whoever reads it. Client-side encryption is usually presented as the option for people who will not self-host. Combine them instead.

Where self-hosting genuinely wins

This is worth stating plainly, because four paragraphs of correction can leave the wrong impression.

No data-mining business model, because there is no business model. Software you can read, which by Lesson 9.2’s standard is the strongest claim available. Your own retention policy, your own schema, your own apps. Jurisdiction you choose rather than accept. And nobody deciding one morning that your account has become a policy question.

Those are real, durable advantages, and they justify the work. “No third party” is simply not among them, because renting a machine is a third party. The honest claim is narrower, and it survives contact with the architecture.

This is Lesson 9.1’s finding for the third time in this module. The consolidation moves, and the accurate description of what moved is smaller than the pitch.


2. Four Commands That Do Not Do What Guides Say

Figure 2. Copy-and-paste instructions, examined.

The admin password goes into your shell history

A typical Nextcloud snap guide gives this:

nextcloud.manual-install admin password123

It tells you to replace those with a username and a strong password from your password manager, and to store the credentials in the password manager immediately.

It rarely says that the password you just typed is now in ~/.bash_history in plaintext, on the server, indefinitely. It is also visible in the process list to any other user on the machine for as long as the command runs.

The fix is ordinary hygiene: clear the history entry afterward, and check whether an interactive form of the command exists for your version.

The same pattern appears in common ownCloud compose files, which set OWNCLOUD_ADMIN_PASSWORD and MYSQL_ROOT_PASSWORD as environment variables, often with the placeholder value owncloud and no warning to change it. Environment variables are readable through container inspection by anybody with access to the container runtime. Hold that thought for Section 3, where it becomes the worked example.

Server-side encryption does not do what guides say

Hardening lists often include this:

Enable Encryption at Rest. Note: Not zero-knowledge (server decrypts). Still protects against physical disk theft.

The caveat about zero-knowledge is correct. The claim about disk theft is not, according to Nextcloud’s own administration manual.

That manual assigns protection against physical tampering and theft to full-disk encryption such as LUKS, which it lists as a separate layer that server-side encryption does not address on its own. It describes server-side encryption as primarily intended for files held on external, third-party storage, so that a remote storage provider cannot read them (Reference 1). Nextcloud’s own security page notes that the keys sit in the server’s memory while a user is logged in, so an attacker with sufficient access could retrieve them (Reference 2).

The manual also carries two warnings that hardening lists usually omit, and they matter more than the feature does. Enabling encryption is hard to reverse through the web interface. And if the encryption keys are lost, the files cannot be recovered, so the keys must be backed up separately and the recovery options considered before you switch it on (Reference 1).

So: if you want protection against somebody removing the disk, use full-disk encryption. If you enable server-side encryption anyway, for external storage, back up the keys first and understand that turning it off again is not a checkbox.

The backup script does not back up the database

This is the most consequential of the four, because it fails silently and you find out on the day you needed it.

A commonly given backup script:

nextcloud.occ maintenance:mode --on
rsync -av /var/snap/nextcloud/common/nextcloud/data/ $BACKUP_DIR/data-$DATE/
mysqldump -u root nextcloud > $BACKUP_DIR/db-$DATE.sql
nextcloud.occ maintenance:mode --off

If you installed Nextcloud from the snap package, it runs its own confined MySQL with its socket inside the snap. A bare mysqldump -u root on the host does not reach it. You get a connection error, or an empty file, and the script continues to the next line regardless.

Maintenance mode is then turned off, the cron job exits, and nothing reports a problem. The rsync succeeded, so there is a directory full of files that looks like a backup.

Nextcloud file data without its database is not restorable. The database holds the file metadata, the users, the shares, the versions and the mapping between what is on disk and what the application believes exists.

The fix is to use the snap’s own tooling, which exists precisely because of this confinement: nextcloud.export for configuration and database, with the data directory handled separately, or nextcloud.mysqldump if you want the database alone (Reference 3). Snap confinement can also interfere with redirecting output to arbitrary paths, so test where the file actually lands.

And add error checking. The script above has none. A backup script that cannot fail loudly is a backup script that fails quietly, for months.

The off-site script hangs in cron

A common off-site step:

tar -czf - /var/vaultwarden /var/snap/nextcloud | \
  gpg --symmetric --cipher-algo AES256 > backup-$DATE.tar.gz.gpg

No passphrase is supplied, so gpg prompts for one. Run from a terminal it works and looks fine. Run from cron, which is where these guides schedule it, there is no terminal and it waits.

Supply the passphrase in batch mode from a file with restricted permissions, and test the job from cron rather than from your shell.

The administration token

Common Vaultwarden compose files hold ADMIN_TOKEN as plaintext. That is a replayable administrator credential sitting in a file, in every backup of that file, in any copy that reaches version control, and in container inspection output.

Vaultwarden logs a notice about this and ships a hashing command that produces an Argon2 string to store instead, with an OWASP preset (Reference 4). You then sign in with the original password rather than with the stored hash. One practical note: the hash contains dollar signs, and every one must be doubled inside a compose file or the substitution will mangle it.


3. The Cheapest Hardening Is Not Publishing It

Figure 3. Two architectures, and the vulnerability that separates them.

The usual hardening list is good. Two-factor authentication, brute-force protection, a password policy, disabling unused apps, log review, the security scanner. All of it is real, and all of it assumes the service is reachable from the internet.

That assumption is the largest single thing you can change, and guides rarely mention it.

The alternative

Bind Nextcloud and Vaultwarden to the machine rather than to the public interface. Run one private network tunnel. Enroll your own devices. Close everything else.

The service now has no public attack surface. An unauthenticated flaw in the application is not reachable by anybody who has not already been given a key. You patch on your own schedule rather than against a clock, and the setup is simpler than the reverse-proxy and certificate work most guides already walk through.

The worked example is in this software

In late 2023 a flaw in the ownCloud graph application returned the output of a server information function to unauthenticated requests. No credentials, no user interaction, trivially automatable. It is listed in the United States catalog of known exploited vulnerabilities, and a module for it shipped in a widely used testing framework (Reference 5).

Now the part that matters here. In container deployments, that output included the process environment, which exposed the administrator password and the database password to anybody who asked (Reference 6).

That is exactly where the common compose files in Section 2 put them.

Behind a tunnel, that disclosure is an ordinary patch on an ordinary Tuesday. On the public internet it is a race against people who automate, and the starting gun goes off when the advisory publishes rather than when you read it.

The trade-offs, because it is not free

Public sharing links stop working, which matters if sending files to clients is part of the job. Mobile access requires the tunnel to be connected. Collaborators have to be enrolled rather than sent a link. And the tunnel is itself software that needs patching, so this is one exposed service rather than none.

For client material it is still the right default, and the sharing problem has a better answer anyway: send an encrypted file rather than publish a server.

The maintenance question, asked the right way

Guides usually budget about two hours a month, with a weekly, monthly and quarterly schedule. The arithmetic is roughly right and the honesty is welcome.

But the maintenance that matters is not on a calendar. A critical disclosure arrives on its own timetable, and it is frequently on a Friday. The real question is not how many hours a month you can find. It is:

Will I patch within two days of a disclosure, during the week I am on an engagement?

For most people, honestly answered, the answer is no. And that is the strongest possible argument for the architecture in this section, because it is Lesson 8.2 again: build it so that the bad outcome is unavailable, rather than promising yourself you will be quick.


4. What a Good Self-Hosting Guide Gets Right

A deployment walkthrough that does not skip the parts that stop people: trusted domains, the firewall, the certificate, and the clients. Most self-hosting guides omit at least one of those and leave the reader stuck.

A fair hosting comparison. Virtual machine against home hardware against dedicated server, with real costs, and the home-server drawbacks stated honestly: your electricity, your upload speed, your uptime, residential addresses getting blocked, dynamic addresses, port forwarding.

Vaultwarden over the official Bitwarden server, for the right reasons: resource use, deployment simplicity and feature availability.

The time cost up front. Four to eight hours to set up and roughly two hours a month to maintain. Saying that before you commit, rather than after, is the difference between informed consent and a surprise.

The 3-2-1 backup rule, translated for self-hosting. Three copies, on two kinds of media, one off-site, where off-site means home if the server is rented and rented if the server is at home.

And the best sentence in Module 9: if you have not tested restoration, you do not have a backup. That is correct, it is rarely said, and it would have caught three of the four problems in Section 2.


5. The Short Version

Decide what the machine is for. If you are self-hosting because you distrust providers, a rented machine does not deliver that and hardware you hold does. If you are self-hosting for control, cost and open software, a rented machine is fine and those reasons are good ones.

Either way, consider encrypting client-side on top. Your own server is still a disk somebody else can read.

Do not publish it. One tunnel, enrolled devices, everything else closed. This is worth more than the whole hardening list and takes less time.

Keep credentials out of history, environment variables and compose files. Clear the history, hash the admin token, change the placeholder passwords.

Make the backup capture the database, add error checking, and then test it: restore it, on a different machine, before you need to.

And answer the Friday question honestly. If you will not patch within two days during a busy week, build the architecture that does not require you to.


Quiz

Question 1. Self-hosting guides list “no provider access, ever” as a benefit. On a rented virtual machine, what is true?

A. It holds for the disk but not for network traffic B. It holds once full-disk encryption is enabled C. The host can read the disk image and snapshot the memory holding your keys D. It holds, because the hypervisor cannot address guest memory

Answer: C

The same guides usually admit it under the drawbacks: the provider has physical access to the server.


Question 2. For the highest-sensitivity data, how does a rented machine compare with a zero-knowledge provider?

A. Weaker, because the provider holds a running system with the key in memory rather than ciphertext B. Stronger, because you control the software C. Equivalent, since both involve a third party D. Stronger, because you can choose the jurisdiction

Answer: A

Jurisdiction choice is a real win. It is a different win from “no provider access.”


Question 3. What is wrong with nextcloud.manual-install admin password123?

A. The snap command requires sudo and will fail B. The password is written to shell history in plaintext and is visible in the process list while it runs C. The username cannot be changed afterward D. It does not create the database

Answer: B

Store the password safely, and also clear the history entry.


Question 4. What does Nextcloud’s own manual say about server-side encryption and physical disk theft?

A. That it protects against theft once a recovery key is configured B. That it protects the database but not the file data C. That theft protection requires the enterprise edition D. That protection against physical tampering and theft comes from full-disk encryption, and that server-side encryption is primarily for external storage

Answer: D

It also warns that enabling it is hard to reverse and that losing the keys means losing the files.


Question 5. Why does the common snap backup script fail?

A. The snap confines its own database, so a bare mysqldump on the host never reaches it, and the script reports success anyway B. Maintenance mode blocks the rsync from reading the data directory C. The rsync flags do not preserve permissions D. The cron schedule conflicts with certificate renewal

Answer: A

File data without its database is not restorable. Use the snap’s own export tooling, and add error checking.


Question 6. An off-site backup script pipes a tar archive into gpg with no passphrase supplied. What happens?

A. It encrypts with a default key derived from the hostname B. It fails immediately with a clear error C. It works from a terminal and hangs when run from cron, because there is nothing to prompt D. It writes the archive unencrypted

Answer: C

That is the worst failure mode: correct when you test it, broken when it matters.


Question 7. What is the single largest hardening measure usually missing from self-hosting guides?

A. Not exposing the services to the internet at all, and reaching them through a private tunnel B. Enabling server-side encryption for all storage C. Running an intrusion detection system on the host D. Changing the SSH port

Answer: A

It is simpler than the reverse proxy most guides already walk through, and it removes the entire class of unauthenticated-flaw exposure.


Question 8. Why is the 2023 ownCloud graph vulnerability the worked example for this lesson?

A. Because it affected Nextcloud as well through shared code B. Because in container deployments it exposed the environment, which is where common compose files put the admin and database passwords C. Because it was the first vulnerability listed in the known exploited catalog D. Because it could only be exploited through the desktop sync client

Answer: B

Unauthenticated, automatable, and listed in the United States known exploited vulnerabilities catalog.


Question 9. What is wrong with a plaintext administration token in a compose file?

A. Nothing, provided the file permissions are restrictive B. It must be regenerated on every container restart C. It is a replayable admin credential sitting in the file, in its backups, and in container inspection output D. It prevents the admin panel from loading over HTTPS

Answer: C

Vaultwarden logs a notice about this and ships a hashing command that produces an Argon2 string to store instead.


Question 10. Guides budget about two hours a month for maintenance. What does that framing miss?

A. That the initial setup takes four to eight hours B. That monitoring services charge for more than fifty checks C. That home servers consume electricity continuously D. That a critical disclosure arrives on its own timetable, so the real question is whether you will patch within two days during a busy week

Answer: D

If the honest answer is no, that is the argument for an architecture that does not depend on you being quick.


References

  1. Nextcloud Administration Manual, server-side encryption configuration: that it is primarily intended for external storage, that full-disk encryption is the layer addressing physical tampering and theft, that enabling it is hard to reverse through the web interface, and that files cannot be recovered if the keys are lost. https://docs.nextcloud.com/server/stable/admin_manual/configuration_files/encryption_configuration.html
  2. Nextcloud’s encryption and hardening page, noting that encryption keys remain in the server’s memory while a user is logged in, so a determined attacker could potentially retrieve them. https://nextcloud.com/encryption/
  3. Nextcloud snap discussion of extracting the database from a snap installation, including the snap’s own dump and export commands and the confinement issues with output redirection. https://forum.snapcraft.io/t/extracting-mysql-database-from-a-nextcloud-snap/25947
  4. Vaultwarden project documentation on enabling the admin page, including the notice logged for a plaintext token and the built-in Argon2 hashing command. https://github.com/dani-garcia/vaultwarden/wiki/Enabling-admin-page
  5. Analysis of CVE-2023-49103 in the ownCloud graph application: unauthenticated, network-reachable, actively exploited, and listed in the United States Known Exploited Vulnerabilities catalog. https://attackerkb.com/topics/G9urDj4Cg2/cve-2023-49103
  6. Reporting on CVE-2023-49103 noting that container deployments pass credentials through the environment, so the disclosure exposed the administrator password and the database password. https://www.helpnetsecurity.com/2023/11/28/cve-2023-49103/

Where This Goes Next

Lesson 9.4 covers search engines and privacy tools, where Lesson 9.2’s verifiability argument applies again and is easier to settle, because there is no encryption claim to check and the question becomes what is logged and for how long.

Module 11 covers client-side encryption in full. Read Section 1 of this lesson before it: the encryption layer is not the option for people who refused to self-host. It is the thing that makes self-hosting on rented hardware defensible.

Lesson 8.5 is worth rereading alongside Section 3. A self-hosted service that is compromised is an incident, and it is an incident involving client material on infrastructure you operate, which means the containment and preservation conflict is yours to resolve rather than a provider’s. The backup you have not tested is also the recovery plan you do not have.


Next lesson: Module 9 Lesson 4: Privacy Tools: Pick a Fingerprinting Strategy, Then Recheck the Stack