this post was submitted on 19 Jun 2026
31 points (94.3% liked)

Selfhosted

59999 readers
451 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam.

  3. Posts here are to be centered around self-hosting. Please ensure it is clear in your post how it relates to self-hosting.

  4. Don't duplicate the full text of your blog or git here. Just post the link for folks to click.

  5. Submission headline should match the article title.

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 3 years ago
MODERATORS
 

Let's say you have access to a remote machine and use it to copy backups occasionally, eg with rsync. Your local machine has credentials stored that allow write access on the remote machine, however if the local account was compromised that could also allow access to the remote machine and the data stored there.

How can you grant access to an account to write remotely, but also protect the data from this account? One possibility could be to change the permissions on the data after it is copied to prevent deletion/interference, although I'm just making this up. Is there a standard practise for this?

top 22 comments
sorted by: hot top controversial new old
[–] glibg10b@lemmy.zip 1 points 22 minutes ago* (last edited 21 minutes ago)

Scheduled snapshots (btrfs or zfs). If the compromised account deletes or modifies files, they're still there in the past snapshots

Filesystem-level snapshots are quite space-efficient because they don't make copies of all the files or even whole files; just the blocks that changed.

[–] Eirikr70@jlai.lu 1 points 53 minutes ago

I have solved that by giving the distant machine the credentials to connect to the local machine. And the distant machine can't be accessed from the outside.

[–] gagootron@feddit.org 4 points 4 hours ago

A system like proxmox backup server can do this scurely. There you can create a user that can only add new backups and read the existing ones, but cannot delete any or read anything else on the remote host.

Otherwise if you only care to protect the remote machine, then something like an ssh chroot jail would also work.

[–] lIlIllIlIIIllIlIlII@lemmy.zip 17 points 7 hours ago (1 children)

Do pull backups instead of push backups: Backup server connects to local machine.

[–] non_burglar@lemmy.world 1 points 4 hours ago (2 children)

What's the rationale for this? Genuinely curious.

[–] pgo_lemmy@feddit.it 3 points 3 hours ago* (last edited 1 hour ago)

If the main site gets compromised the credentials there must be considered lost and known to che attackers.

with a pull backup that's not an issue because the main site has no access to the remote system; it is a process on the remote site that has credentials to access the main site and not the other way around.

the remote system may ~~receive~~ retrieve a compromised copy of the data, but the attacker cannot tamper with previous backups so recovery is still possible.

[–] bcnelson@lemmy.world 10 points 4 hours ago (1 children)

The reasoning is that your backup server should be more secure than production. Production has to have a bunch of stuff open in order to be useful and convenient. The backup server does not. It can be basically fully locked down.

[–] Onomatopoeia@lemmy.cafe 3 points 4 hours ago

To add - by doing pulls the backup server uses different credentials to run than the credentials used to perform pulls.

Backup server has it's own credentials database, machines being backed up have their own database. Backup service in backup server uses appropriate credentials from machine being backed up to access the data there (shares, etc). So credentials from compromised machine are unrelated to credentials for backup server.

And if backups are done properly (full on a schedule, daily incrementals, or something similar) you should be able to revert to a known-good state with minimal data loss.

[–] ShellMonkey@piefed.socdojo.com 21 points 10 hours ago

Encrypt before send, and if you want to have protection against deletions of the data have a cold backup offline other than during the copy.

[–] motruck@lemmy.zip 6 points 8 hours ago

Append only mode.

[–] eleijeep@piefed.social 7 points 9 hours ago (1 children)

Funny thing is that blockchains are actually good for this type of thing. Too bad crypto bros got a hold of it.

[–] HelloRoot@lemy.lol 6 points 9 hours ago* (last edited 9 hours ago)

I think you could do it somewhat like hetzner does for their storage boxes. You get an account that has read and write access to a directory and nothing outside. The accound can only run a limited set of commands, like ls, cat, nano, rsync etc. but has no access to commands that modify the filesystem.

Then you can use a copy on write fs like btrfs and make scheduled staggered snapshots.

I usually do 1x per year, 1x per month of current year, 4 per week of current montg, 7 per day in current week.

I have no clue what they use to limit the user accounts like that btw. but maybe that gives you a new jump off point for further research.

[–] civ@lemmy.civl.cc 3 points 8 hours ago

Append only, like others are saying.

[–] zorflieg@lemmy.world 4 points 9 hours ago

What you are talking about is Immutability and an append only backup. The s3 file system and some others has Immutability built in. Not all backups can do append only.

[–] frongt@lemmy.zip 3 points 9 hours ago

WORM: write once, read many. Any good backup software supports this.

You could also keep offline backups. You can't compromise what you can't reach.

[–] xia@lemmy.ca 2 points 9 hours ago

You've got the right idea with the permission change... the key is that you can have code executing on the remote side with different permissions. So the writer process has permission to write in one directory, and the turnsyle procees (often the root super-user) rotates the files or directories at a different time (or on a signal, sometimes).

[–] TheFogan@programming.dev 2 points 9 hours ago

I mean depends on the solution you are using, but you can have multiple accounts on the remote backup. IE so upon completion of the backup. The remote machine moves the backup to an offline or read only share (depending if you need those credentials to access the data again later),

Obviously most important thing is your credentials that make the backup... should be very limited in scope to just doing those backups.

[–] bacon_pdp@lemmy.world 1 points 9 hours ago

Append only permissions.

Encrypted deltas.

Basically the time of the connection is the name of the only that folder that you have access to.

You can also setup a yubikey (or nitrokey) that requires you to physically process and would be immune to the host being compromised.

[–] corsicanguppy@lemmy.ca 0 points 8 hours ago (2 children)

Are you connecting to the victim to push a backup into storage? If so, there's SO much you should improve on that.

[–] glibg10b@lemmy.zip 1 points 15 minutes ago

What are the vulnerabilities that you're afraid of? Can you answer this purely from the info OP gave, i.e. without making assumptions about what the server authorizes the phone to do? OP's post does not indicate that they're violating the principle of least privilege in any way.

[–] motruck@lemmy.zip 3 points 8 hours ago