GPG as SSH agent
Did you know? It's the second time I'm doing this change because my SSD crashed and I DIDN'T PUSH. Rrrrr
This commit is contained in:
parent
7ebbfb5186
commit
7d934e8e14
|
@ -10,27 +10,6 @@ export EDITOR=nvim
|
||||||
export VISUAL=nvim
|
export VISUAL=nvim
|
||||||
export BROWSER=firefox
|
export BROWSER=firefox
|
||||||
|
|
||||||
# Load ssh-agent... ONCE
|
|
||||||
|
|
||||||
SSH_ENV="$HOME/.ssh/environment"
|
|
||||||
|
|
||||||
start_agent() {
|
|
||||||
ssh-agent > "${SSH_ENV}"
|
|
||||||
chmod 600 "${SSH_ENV}"
|
|
||||||
. "${SSH_ENV}" > /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -f "${SSH_ENV}" ]
|
|
||||||
then
|
|
||||||
. "${SSH_ENV}" > /dev/null
|
|
||||||
if [ ! -d "/proc/${SSH_AGENT_PID}" ] || [ "$(cat "/proc/${SSH_AGENT_PID}/comm")" != "ssh-agent" ]
|
|
||||||
then
|
|
||||||
start_agent
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
start_agent
|
|
||||||
fi
|
|
||||||
|
|
||||||
direnv() { # environment variable name, path
|
direnv() { # environment variable name, path
|
||||||
export "$1"="$2"
|
export "$1"="$2"
|
||||||
mkdir -p "$2"
|
mkdir -p "$2"
|
||||||
|
@ -127,4 +106,35 @@ prependpath "$HOME/.config/scripts"
|
||||||
prependpath "$HOME/.termux/bin"
|
prependpath "$HOME/.termux/bin"
|
||||||
)
|
)
|
||||||
|
|
||||||
# For superseding commands with better ones if they are present
|
|
||||||
|
if grep -q enable-ssh-support "$GNUPGHOME/gpg-agent.conf" 2> /dev/null
|
||||||
|
then
|
||||||
|
# Use GPG as SSH agent
|
||||||
|
unset SSH_AGENT_PID
|
||||||
|
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
|
||||||
|
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
|
||||||
|
fi
|
||||||
|
export GPG_TTY=$(tty)
|
||||||
|
gpg-connect-agent updatestartuptty /bye >/dev/null
|
||||||
|
|
||||||
|
else
|
||||||
|
# Start regular SSH agent if not already started
|
||||||
|
SSH_ENV="$HOME/.ssh/environment"
|
||||||
|
|
||||||
|
start_agent() {
|
||||||
|
ssh-agent > "${SSH_ENV}"
|
||||||
|
chmod 600 "${SSH_ENV}"
|
||||||
|
. "${SSH_ENV}" > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -f "${SSH_ENV}" ]
|
||||||
|
then
|
||||||
|
. "${SSH_ENV}" > /dev/null
|
||||||
|
if [ ! -d "/proc/${SSH_AGENT_PID}" ] || [ "$(cat "/proc/${SSH_AGENT_PID}/comm")" != "ssh-agent" ]
|
||||||
|
then
|
||||||
|
start_agent
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
start_agent
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue