我想使用GPG认证子密钥而不是SSH密钥。
我还想使用gpg-agent来管理这些密钥的密码缓存。
我是在无头环境中运行的,所以我想在我的密码输入程序中使用pinentry-curses,但是我对在无头环境中工作的任何东西都很满意。
我的开发工作流程是这样的,我在多个tmux会话和窗格中工作,并且需要能够从它们中的任何一个进行git push。
当我尝试这样做时,问题就会发生。而不是在我当前的窗格中弹出pinentry,而是在一个随机的其他窗格中弹出(有时可能根本没有窗格,但可能有太多的内容需要搜索)。要解决这个问题,我需要关闭该窗格和pinentry-curses,即使这样,它仍然有时会失败。
我现在的配置如下所示,尽管在过去的几周里我尝试了大量的尝试来实现这个功能。
# ~/.zshrc
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
if [[ $SSH_AUTH_SOCK == /tmp/* ]]; then
ln -sf $SSH_AUTH_SOCK $HOME/.ssh-agent-sock
export SSH_AUTH_SOCK=$HOME/.ssh-agent-sock
fi
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null# ~/.gnupg/gpg-agent.conf
pinentry-program /usr/sbin/pinentry-curses
default-cache-ttl 600
max-cache-ttl 7200
enable-ssh-support# ~/.gnupg/gpg.conf
use-agent# ~/.gnupg/sshcontrol
MYFINGERPRINTS# ~/.ssh/config
Host localhost
ForwardAgent yes
AddKeysToAgent ask# ~/.zshrc
export GPG_TTY=$(tty)# ~/.gnupg/gpg-agent.conf
pinentry-program /usr/bin/pinentry-curses
default-cache-ttl 600
max-cache-ttl 7200
enable-ssh-support# ~/.gnupg/gpg.conf
use-agent# ~/.gnupg/sshcontrol
MYFINGERPRINTS# ~/.ssh/config
Host localhost
ForwardAgent yes
AddKeysToAgent ask
Match host * exec "gpg-connect-agent UPDATESTARTUPTTY /bye"发布于 2020-05-19 14:35:32
问题是,每次打开终端时都要调用gpg-connect-agent updatestartuptty,所以定位器本身就是最新的shell。
您真正想要的不是最新的shell终端,而是您正在连接的终端(当调用ssh时)。
为此,最简单的方法是告诉. .ssh/config从所连接的tty执行update命令。这是你错过的魔法线:
Match host * exec "gpg-connect-agent UPDATESTARTUPTTY /bye"https://unix.stackexchange.com/questions/554153
复制相似问题