GPG key ask everytime

Hello,

I’m new to org-roam and it seems a good fit for storing my information.
The last point I struggle with is that I need a way to encrypt my files (all or only some). I setup GPG and it works well, I can create and open files that are encrypted.

I have a problem when I create a new file: it asks me twice my GPG passphrase, everytime. It’s quite cumbersome…
When I open a file, it asks my passphrase once, but then gpg-agent get it right. But not on creation.
Is that a normal behavior? Or I miss some configuration?

Thank you in advance,
Denis

ps: sorry for my English…

Hello,
I finally fix my problem. It was an epa configuration problem, not even linked to org-roam…
If someone is interested, without configuration emacs doesn’t use keys, but symmetrical encryption, so it asks password every time.
With the variable:
(setq epa-file-encrypt-to "xxx@yyy.zzz")
It uses the key specified for encrypting .gpg file.

Have a nice day,
Denis

I’m curious, after you added the setq epa-file-encrypt-to, does it still ask which key to use? I’ve added that to my .emacs config but when I save an org-roam file, it still makes me mark the key that I want to use. Also, when you use this method, does it ever ask your passphrase to decrypt? It doesn’t on mine, emacs just happily opens the org-roam encrypted file. . . not much use to encryption in this method. However, the files themselves as saved are gpg encrypted and ask for a passphrase if I try to open outside of emacs.

I’ve tried it on my end; apparently, epa-file-encrypt-to acts as a filter, and even if there remains only one possible key, you will still have to select it for encryption. I would advise to look into File Local Variables. Prepending your notes with something like this ought to be enough:

# -*- mode: org; coding: utf-8; epa-file-encrypt-to: ("$your_key") -*-

It is cached; see Caching Passphrases.

Thanks for the reply! I’ll take a look at adding that to my org files, would need to add to the general template I suppose. Appreciate the nudge in the right direction.