# GPG key ask everytime

**URL:** <https://org-roam.discourse.group/t/gpg-key-ask-everytime/1334>\
**Category:** Troubleshooting\
**Created:** [March 2, 2021, 11:45am UTC](https://org-roam.discourse.group/t/gpg-key-ask-everytime/1334 "2021-03-02T11:45:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmi](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@dmi](https://org-roam.discourse.group/u/dmi)\
**Post date:** [March 2, 2021, 11:45am UTC](https://org-roam.discourse.group/t/gpg-key-ask-everytime/1334/1 "2021-03-02T11:45:31Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![dmi](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@dmi](https://org-roam.discourse.group/u/dmi)\
**Post date:** [March 3, 2021, 5:06pm UTC](https://org-roam.discourse.group/t/gpg-key-ask-everytime/1334/2 "2021-03-03T17:06:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kregerator](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@kregerator](https://org-roam.discourse.group/u/kregerator)\
**Post date:** [May 12, 2021, 1:28pm UTC](https://org-roam.discourse.group/t/gpg-key-ask-everytime/1334/3 "2021-05-12T13:28:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![zaeph](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/zaeph/32/764_2.png) [@zaeph](https://org-roam.discourse.group/u/zaeph)\
**Post date:** [May 12, 2021, 1:46pm UTC](https://org-roam.discourse.group/t/gpg-key-ask-everytime/1334/4 "2021-05-12T13:46:22Z")

</div>

> [@kregerator](#):
>
> 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.

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](https://www.gnu.org/software/emacs/manual/html_node/elisp/File-Local-Variables.html). Prepending your notes with something like this ought to be enough:

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

```

> [@kregerator](#):
>
> 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.

It is cached; see [Caching Passphrases](https://www.gnu.org/software/emacs/manual/html_mono/epa.html#Caching-Passphrases).

---

<div class="post-metadata">

**Author:** ![kregerator](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@kregerator](https://org-roam.discourse.group/u/kregerator)\
**Post date:** [May 12, 2021, 3:00pm UTC](https://org-roam.discourse.group/t/gpg-key-ask-everytime/1334/5 "2021-05-12T15:00:58Z")

</div>

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.
