Let systemd use password protected ssh and gpg keys

3

1

I have setup Obnam backup to do an sftp backup of the system on an external server. When I run the command it executes properly.

The way it connects to the sftp is with my ssh key. And it encrypts the content with my GPG key.

I am trying to get systemd to execute it automatically everyday.

So I have a backup.servive which looks like that:

[Unit]
Description="Online Backup"
Requires=network-online.target
After=network-online.target

[Service]
User=my_user
ExecStart=/path/to/my/backup/script

And then I also created a timer unit backup.timer:

[Unit]
Description="Run backup daily and on boot"

[Timer]
OnBootSec=15min
OnUnitActiveSec=1d

[Install]
WantedBy=timers.target

My problem now is how to integrate my ssh and gpg keys.

If I run the service with systemctl then the script (that works when run manually) now fails with an SSH exception which I believe is due to the lack of access to my password to such key.

I guess the same problem would arise with the GPG key, should the script get to the point where it uses it to encrypt the content.

So for the moment the question is how to give systemd access to such passwords? An equivalent to the ssh-agent and keyring I use when I run it manually.

Bastian

Posted 2016-06-18T16:34:42.483

Reputation: 151

Maybe start the discussion by showing your script. – U. Windl – 2019-04-29T10:21:18.737

No answers