windowsservicegnupgasymmetric

Gpg4Win batch asymmetric encryption from Windows service with LocalSystem account


I'd like run the Duplicati backup soft as a Windows service for 2 reasons : gather all users files and run even no one is logged in. Also, even if the system was a single user one, I wouldn't like to rely on supplying the user's Windows password either to the service or a scheduled on-boot job, because if user changes his password, then he must remember to update the service or job.

I first tested (seemed OK) from within a user account i.e. not as a service, with a small subset of the user's files with these parameters and a private key with no passphrase:

--no-default-keyring --keyring c:\users\utilisateur\AppData\Roaming\gnupg\pubring.kbx --default-key FULLFINGERPRINTHERE --default-recipient-self

When ran as a service I get this error (translated to english):

GPG execution failure with "C:\Program Files (x86)\Gpg4win\..\GnuPG\bin\gpg.exe --batch --passphrase-fd 0 --no-default-keyring --keyring c:\users\utilisateur\AppData\Roaming\gnupg\pubring.kbx --default-key FULLFINGERPRINTHERE --default-recipient-self --encrypt": gpg: Warning: not using 'FULLFINGERPRINTHERE' as default key: No gpg secret key: all values passed to '--default-key' ignored gpg: no valid recipient gpg: [stdin]: encryption failed: No identity

Please notice the parameters --batch --passphrase-fd 0 --encrypt added by Duplicati. I added --no-default-keyring & --keyring path-to-user-gpg-data as a workaround to --secret-keyring <file> being obsolete in gpgv2 because secret keys are now stored in private-keys-v1.d directory.

Please any hint ?

Thank you


Solution

  • Got it working with --home-dir path and removed the --[no-default-]keyring stuff. First I didn't try because the manual says it is only considered in command line.