{bash,zsh}rc: use gpg for ssh, if it has sshcontrol

Resolves: #60
This commit is contained in:
Aminda Suomalainen 2020-03-03 21:18:21 +02:00
parent 64d5fef6f3
commit 1e707dd586
Signed by: Mikaela
GPG Key ID: 99392F62BAE30723
2 changed files with 30 additions and 6 deletions

View File

@ -214,9 +214,21 @@ if [[ $USER = "root" ]]; then
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
fi
# Copied from https://homepages.see.leeds.ac.uk/~eeaol/notes/2012/03/how_to_only_type_ssh_passphrase_once/
# if gpg[-agent] has sshcontrol file, use it as ssh-agent. sshcontrol should
# include the authentication subkey keygrip from
# `gpg --with-keygrip --list-keys`
# Assumption: there is not going to be a sshcontrol file if `gpgconf` is not
# installed or `sshcontrol` is trivial to remove.
if [ -f ~/.gnupg/sshcontrol ]; then
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
# otherwise use the normal ssh-agent
else
# if the output is going to /dev/null, it's non/existence doesn't matter
(ssh-agent -a /tmp/$USER.agent > /dev/null 2>&1)
export SSH_AUTH_SOCK=/tmp/$USER.agent
(ssh-agent -a /tmp/$USER.agent > /dev/null 2>&1&)
fi
# OS X ls colours (copied from https://apple.stackexchange.com/questions/33677/
export CLICOLOR=1

View File

@ -165,9 +165,21 @@ export LESS_TERMCAP_us=$'\E[01;32m'
# Sets environment variable CPUARCH to output of "uname -p" & UNAME to "uname"
CPUARCH=$(uname -p)
# Copied from https://homepages.see.leeds.ac.uk/~eeaol/notes/2012/03/how_to_only_type_ssh_passphrase_once/
# if gpg[-agent] has sshcontrol file, use it as ssh-agent. sshcontrol should
# include the authentication subkey keygrip from
# `gpg --with-keygrip --list-keys`
# Assumption: there is not going to be a sshcontrol file if `gpgconf` is not
# installed or `sshcontrol` is trivial to remove.
if [ -f ~/.gnupg/sshcontrol ]; then
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
# otherwise use the normal ssh-agent
else
# if the output is going to /dev/null, it's non/existence doesn't matter
(ssh-agent -a /tmp/$USER.agent > /dev/null 2>&1)
export SSH_AUTH_SOCK=/tmp/$USER.agent
ssh-agent -a /tmp/$USER.agent > /dev/null 2>&1
fi
# If we are on Linux, enable apt progress bar and colours
if [[ $USER = "root" ]]; then