plugins icon indicating copy to clipboard operation
plugins copied to clipboard

os-git-backup: optional encryption of the pushed configuration

Open Githopp192 opened this issue 1 month ago • 4 comments

Important notices Before you add a new report, we ask you kindly to acknowledge the following:

  • [x] I have read the contributing guide lines at https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md
  • [x] I have searched the existing issues, open and closed, and I'm convinced that mine is new.
  • [x] When the request is meant for an existing plugin, I've added its name to the title.

Is your feature request related to a problem? Please describe.

The Git backup provider (os-git-backup) pushes config.xml in clear text to the remote repository. config.xml contains password hashes, API keys and secrets, VPN keys and private keys of certificates and CAs, so every remote copy - and every backup of the machine that hosts the remote repository - carries the full secret material of the firewall in clear text, for every revision ever pushed.

Describe the solution you'd like

An optional encryption setting for the Git provider, for example:

Encrypted remote, plain local history (preferred): the local repository in /conf/backup/git stays as it is (diffable history), only the content sent to the remote is encrypted (e.g. via git-remote-gcrypt or age/OpenPGP). The remote host never sees clear text; anyone holding the key can clone and get the full, diffable history back. Encrypt the file before the commit with the same mechanism as the encrypted download. Simple, but every revision becomes an opaque blob (no diffs, the repository grows by the full file size per commit) - acceptable as an opt-in. Either option should be off by default, so existing setups keep working.

Describe alternatives you've considered

Restricting access on the remote host (dedicated user, git-shell, from= restriction in authorized_keys, mode 700/600, core.sharedRepository=0600). This protects the live repository, but not copies of it (VM snapshots, backups of the remote host). Encrypting the file system of the remote host - protects only against offline access to that disk, not against backups taken above the file system layer. Using the Nextcloud provider instead - loses the per-change git history that makes the Git provider valuable (one commit per configuration change, with the API path in the commit message).

Additional context

Other places in OPNsense already offer encryption:

System > Configuration > Backups > Download: "Encrypt this configuration file" the Nextcloud and Google Drive backup providers have an encryption password The Git provider has no such option, so it is currently the only remote backup provider without encryption at rest on the remote side.

The trade-off between encryption and diffability is real; option 1 keeps both for whoever holds the key. A short note in the documentation that the Git provider stores config.xml unencrypted on the remote would already help users judge where to host the repository.

OPNsense version: OPNsense 26.7.7-amd64 FreeBSD 15.1-RELEASE-p4 OpenSSL 3.5.9

Plugin: os-git-backup : os-git-backup (installed) --> 1.1_5

Githopp192 avatar Oct 24 '26 14:10 Githopp192

best use sftp for encrypted backups, the git method is specifically designed for tracking changes, which isn't possible when encrypting the data.

AdSchellevis avatar Oct 25 '26 13:10 AdSchellevis

This is something I've previously requested as well, and I have to say I don't understand the resistance here. It is crazy to push OPNsense config to any remote without encryption, even in an enterprise scenario where a company may operate its own internal git forge. Breaches happen, and a compromised OPNsense backup is not good, to say the least. The git method still has value for version control, even when encrypted, and of course encryption should be strictly opt-in and would not preclude diffing on the local side, as @Githopp192 mentioned.

Another significant benefit is for home users who are currently stuck with Google Drive as our only backup method. The trustworthiness (or lack thereof) of American tech companies is no longer up for debate in 2026, and I find myself wanting to completely de-Google. Being able to push encrypted backups to a git repo would allow us to choose from any number of public git services, and simply push the encrypted config to a private repo, as well as leverage mirroring for redundancy.

SFTP does not appear to be a good solution for that case, from what I can tell, as I'm unable to find any reputable cloud services suitable for dropping a few MB of backups in. Rsync.net has a minimum 800 GB account, which I definitely don't want or need. Another alternative would be S3-compatible object storage, but that means creating an entirely new plugin of course.

ralgar avatar Nov 04 '26 07:11 ralgar

Yeah, and as for SFTP, I tried using the free tier of Docevent.io to do automated encrypted backups to B2 Backblaze. But their (Docevent.io) free tier only supports password authentication, while os-sftp-backup only supports SSH key authenication. And paying $2/month just for this doesn't seem worth it.

I guess I'll have to wait till I set up my homeserver and am able to SFTP into it...

GrassGlass avatar Nov 16 '26 03:11 GrassGlass

I built a separate backup provider along the lines of the second option in the issue. It uses OPNsense’s encrypted export format before committing to Git. That keeps snapshot history in a Git remote and lets you decrypt a selected export for recovery. Readable configuration diffs require decrypting the snapshots first.

It runs through the native Backups screen and scheduler. I maintain it independently through VH & Co. If you’re evaluating it on a test appliance, these pages describe the setup and how to recover a snapshot.

Installation and compatibility · Isolated restore

michielvha avatar Nov 28 '26 16:11 michielvha