Load systemd encrypted credentials

This commit is contained in:
cvlc12 2024-07-31 20:24:14 +00:00 committed by cvlc12
parent a4b65cf710
commit aefc9d61ba
3 changed files with 29 additions and 0 deletions

View File

@ -232,7 +232,10 @@ properties:
passcommand/repokey/keyfile encryption. Note that if both
encryption_passcommand and encryption_passphrase are set, then
encryption_passphrase takes precedence. Defaults to not set.
This can also be used to access encrypted systemd service
credentials (stored in /etc/credstore.encrypted/borgpw/).
example: "secret-tool lookup borg-repository repo-name"
example: "cat ${CREDENTIALS_DIRECTORY}/borgpw_backupserver1"
encryption_passphrase:
type: string
description: |

View File

@ -29,6 +29,29 @@ For example, to ask the *Pass* password manager to provide the passphrase:
encryption_passcommand: pass path/to/borg-repokey
```
### Using systemd service credentials
Borgmatic supports using encrypted [credentials](https://systemd.io/CREDENTIALS/).
Save your passwords as encrypted credentials to `/etc/credstore.encrypted/borgpw/`, e.g.,
```
# mkdir /etc/credstore.encrypted/borgpw
# systemd-ask-password -n | systemd-creds encrypt --name=borgpw_backupserver1 - /etc/credstore.encrypted/borgpw/backupserver1
# systemd-ask-password -n | systemd-creds encrypt --name=borgpw_backupserver2 - /etc/credstore.encrypted/borgpw/backupserver2
...
```
Ensure that the file names, (e.g. backupserver1) match the corresponding part of
the `--name` option *after* the underscore (_), and that the folder name matches
the part *before* the underscore.
Then uncomment or use the following in your configuration file. Adjust `borgpw_backupserver1`
according to the name given to the credential.
```yaml
encryption_passcommand: "cat ${CREDENTIALS_DIRECTORY}/borgpw_backupserver1"
```
### Environment variable interpolation
<span class="minilink minilink-addedin">New in version 1.6.4</span> borgmatic

View File

@ -9,6 +9,9 @@ ConditionACPower=true
[Service]
Type=oneshot
# Load encrypted credentials.
LoadCredentialEncrypted=borgpw:/etc/credstore.encrypted/borgpw/
# Security settings for systemd running as root, optional but recommended to improve security. You
# can disable individual settings if they cause problems for your use case. For more details, see
# the systemd manual: https://www.freedesktop.org/software/systemd/man/systemd.exec.html