我使用 GNU 的密码存储(pass)来保存我的所有密码,包括我的电子邮件密码。我在 GPG 密钥上设置了一个密码短语,然后记住了gpg-agent
一个小时。我还有一个 cron 作业,它会定期提取我的电子邮件,使用pass
.
这意味着 cron 作业仅在我输入密码时才起作用,以便gpg-agent
记住密码。否则 cron 作业会失败。
我希望始终为这项 cron 作业记住密码,但不为其他进程记住密码。有没有办法这样做?
处理这种用例的正确方法是什么?我很想一起删除密码。
我使用 OS X 和存储在 Yubikey 中的私有 SSH 密钥来 SSH 到远程服务器。每次我的 Mac 睡眠和唤醒后,我都需要运行gpg-connect-agent updatestartuptty /bye
. 这个答案说我可以~/.ssh/config
像这样输入这个命令
Match host * exec "gpg-connect-agent updatestartuptty /bye"
但这不起作用,因为我需要将GPG_TTY
上下文中的 env var设置exec
为我当前 shell 的tty
值。我用鱼壳,里面有这个~/.config/fish/config.fish
set -x GPG_TTY (tty)
但是当 sshexec
运行时,tty 会返回not a tty
。这些都是我的环境变量。
cat ~/.ssh/config
...
Match host * exec "env > /tmp/t"
...
[run ssh some-host command]
cat /tmp/t
PWD=/Users/dxia
COLORFGBG=12;8
LC_TERMINAL=iTerm2
LOGNAME=dxia
GPG_TTY=not a tty
LANG=en_US.UTF-8
XPC_FLAGS=0x0
TERM=xterm-256color
TMPDIR=/var/folders/x1/f9sjnv7j43z73sdv5lsk3r8h0000gp/T/
EDITOR=/usr/bin/vim
COLORTERM=truecolor
LC_TERMINAL_VERSION=3.4.10
XPC_SERVICE_NAME=0
__CF_USER_TEXT_ENCODING=0x1F6:0x0:0x0
HOME=/Users/dxia
ITERM_PROFILE=Default
TERM_PROGRAM=iTerm.app
TERM_PROGRAM_VERSION=3.4.10
DISPLAY=/private/tmp/com.apple.launchd.6iiZkY4Tos/org.xquartz:0
USER=dxia
SHLVL=1
COMMAND_MODE=unix2003
TERM_SESSION_ID=w0t0p1:5945A63C-850F-4DCF-A605-F72860D9D72C
__CFBundleIdentifier=com.googlecode.iterm2
SHELL=/usr/local/bin/fish
ITERM_SESSION_ID=w0t0p1:5945A63C-850F-4DCF-A605-F72860D9D72C
PATH=/opt/homebrew/sbin:/opt/homebrew/bin:/Users/dxia/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/sbin:/usr/local/opt/fzf/bin:/opt/homebrew/opt/fzf/bin:/Users/dxia/.jenv/shims:/Users/dxia/.jenv/shims:/Users/dxia/.rbenv/shims:/Users/dxia/google-cloud-sdk/bin
SSH_AUTH_SOCK=/Users/dxia/.gnupg/S.gpg-agent.ssh
我怎样才能Match host * exec ...
继承 tty?或者有没有更好的方法让 OS X 在睡眠/唤醒后与 Yubikey + SSH 一起工作?
问题: - 当我通过时重复请求密码show <name of credential>
。
做一些谷歌搜索,我发现你可以用 gpg-preset-passphrase 做到这一点,但是我不确定从哪里得到它或者它是否包含在 gpg 发行版中。
这是我正在运行的 gpg 的当前版本。
有谁知道如何安装 gpg-preset-passphrase?
gpg --version
gpg (GnuPG) 2.0.22
libgcrypt 1.5.3
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, ?, ?, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
当我运行 gpg2 时,每次使用时都会提示我输入密码。根据我对gpg-agent
手册页的阅读,我应该只在第一次得到提示。
gpg-agent is a daemon to manage secret (private)
keys independently from any proto-col. It is
used as a backend for gpg and gpgsm as well as
for a couple of other utilities.
The agent is automatically started on demand
by gpg, gpgsm, gpgconf, or gpg-connect-agent.
Thus there is no reason to start it manually.
...
--default-cache-ttl n
Set the time a cache entry is valid to n
seconds. The default is 600 sec- onds.
Each time a cache entry is accessed, the
entry's timer is reset. To set an entry's
maximum lifetime, use max-cache-ttl.
--max-cache-ttl n
Set the maximum time a cache entry is valid
to n seconds. After this time a cache
entry will be expired even if it has been
accessed recently or has been set using
gpg-preset-passphrase. The default is 2
hours (7200 seconds).
如果我没看错,gpg2
在我第一次使用它时调用应该提示输入密码,然后,如果我在接下来的 600 秒内再次运行它,我将不会再收到提示。跑步
gpg2 --export-secret-keys --armor [email protected] > /dev/null
给了我这个:
┌─┐
│ Please enter the passphrase to export the OpenPGP secret key: │
│ "John Doe (asdf) <[email protected]>" │
│ 2048-bit RSA key, ID EB7B49EAD38DE665, │
│ created 2018-10-09. │
│ │
│ │
│ Passphrase: _ │
│ │
│ <OK> <Cancel> │
└─┘
正在运行的快速ps aux
显示:gpg-agent
ps aux | grep gpg-agent
jdoe 14089 0.1 0.1 100884 3588 ? SLs 18:50 0:07 /usr/bin/gpg-agent --supervised
唉,此后立即再次运行 gpg2 --export-secret-keys...
再次提示我输入密码。
更多细节:
pinentry-curses
$GPG_TTY
在我的.bashrc
gpg2 --version -> gpg (GnuPG) 2.2.4