2

I have passwords stored in .authinfo.gpg file which I only need for Gnus. I never store passwords for machines or localhost in this .authinfo.gpg file (or in any other file).

The problem is when I use Tramp (e.g. C-x C-f, then type in su::), I constantly get prompted for password for .authinfo.gpg which I don't need.

Is it possible to disable password prompt for .authinfo.gpg when using Tramp? An alternative solution would be to use some other file for Gnus, is there a way to do this?

2 Answers 2

3

You can either use this (I base mine on the command-line arguments):

(setq tzz-gnus-running-p (member "gnus" command-line-args))
(setq auth-sources (if tzz-gnus-running-p
                       '("~/.gnus.json.gpg")
                       '("~/.authinfo.json.gpg")))

or customize tramp-completion-use-auth-sources:

tramp-completion-use-auth-sources is a variable defined in ‘tramp.el’.
Its value is t
...
Whether to use ‘auth-source-search’ for completion of user and host names.
1
  • 1
    Setting tramp-completion-use-auth-sources to nil does not work for me. I still get prompted for .authinfo.gpg password each time I try to use tramp with /su::/.
    – Gleb
    Commented Dec 4, 2020 at 22:04
0

I had the exact same problem and found the answer in the Emacs documentation after (setq tramp-completion-use-auth-sources nil) didn't work for me. Here is the relevant snippet from the documentation:

In case you do not want to use an authentication file for TRAMP passwords, use connection-local variables like this:

(connection-local-set-profile-variables  'remote-without-auth-sources '((auth-sources . nil)))


(connection-local-set-profiles  '(:application tramp) 'remote-without-auth-sources)

This has the expected result of TRAMP prompting for a password in the minibuffer (not authinfo.gpg) when trying to open a file as root - in my case, M-o r after using counsel-find-file.

Note that password-cache-expiry applies to TRAMP, so you can tweak this setting to find a good balance between convenience and security regarding the password prompt frequency.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.