Answers:
我使用一个称为pass的简单密码管理器。它提供了一个简单的命令行界面,非常适合与Emacs集成。后备存储是GPG加密的GIT存储库。它实际上附带了Emacs软件包,尽管我不使用它。我的界面很简单:
(defun my-fixup-gpg-agent (frame)
"Tweak DISPLAY and GPG_TTY environment variables as appropriate to `FRAME'."
(when (fboundp 'keychain-refresh-environment)
(keychain-refresh-environment))
(if (display-graphic-p frame)
(setenv "DISPLAY" (terminal-name frame))
(setenv "GPG_TTY" (terminal-name frame))
(setenv "DISPLAY" nil)))
(add-hook 'after-make-frame-functions 'my-fixup-gpg-agent)
;; Simple caching
(defvar my-cached-passwords
nil
"Cache of passwords. Stored in plain text so you only want to cache
them if of low value.")
(defun my-pass-password (pass-name &optional cache)
"Return the password for the `PASS-NAME'."
(let ((cached-pass (assoc-default pass-name my-cached-passwords)))
(if cached-pass
cached-pass
(when (selected-frame)
(my-fixup-gpg-agent (selected-frame))
(let ((new-pass (chomp
(shell-command-to-string
(format "pass %s" pass-name)))))
(when (and new-pass cache)
(add-to-list 'my-cached-passwords (cons pass-name new-pass)))
new-pass)))))
Tramp使用auth-sources后端管理密码。它需要.authinfo中的一些专门条目,例如
machine melancholia port scp login daniel password geheim
有关详细信息,请阅读Tramp手册的“密码处理”一章。
auth-sources还具有一些功能,可以即时创建密码条目。我从未尝试过使用Tramp进行此功能,但也许您需要进行一些调查。