Created
January 30, 2020 15:11
-
-
Save apathor/6c47abff931b31ec2d979e403e7bed60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ; -*-shell-script-*- | |
# MFL's bash profile config for ssh and gpg agent | |
# shellcheck disable=SC1090 | |
keyagents() { | |
# TODO | |
# add keys | |
# option to use gpg-agent for ssh | |
# ssh-agent | |
if type ssh-agent &>/dev/null; then | |
# source environment file if it exists | |
SSH_FILE="$HOME/.ssh-agent-info" | |
if [ -f "$SSH_FILE" ]; then | |
. "$SSH_FILE" &>/dev/null | |
fi | |
# start ssh-agent if it is not running | |
if [ -z "$SSH_AUTH_SOCK" ] \ | |
|| ! kill -0 "$SSH_AGENT_PID" &>/dev/null; then | |
ssh-agent -s > "$SSH_FILE" | |
. "$SSH_FILE" &>/dev/null | |
# MAYBE trap 'kill $SSH_AGENT_PID' 0 | |
fi | |
# update environment | |
export SSH_AUTH_SOCK | |
export SSH_AGENT_PID | |
fi | |
## gpg-agent | |
if type gpg-agent &>/dev/null; then | |
GPG_TTY=$(tty) | |
export GPG_TTY | |
# SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" | |
# export GPG_TTY | |
# export SSH_AUTH_SOCK | |
fi | |
} | |
keyagents |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment