Revamp SSH_AUTH_SOCK

This commit is contained in:
John Mertz 2022-11-07 21:44:37 -05:00
parent 742a3db2e1
commit eb5b21e2e8
3 changed files with 21 additions and 4 deletions

View File

@ -6,11 +6,17 @@ systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT
source ${HOME}/.dotfiles/bash/bash_aliases source ${HOME}/.dotfiles/bash/bash_aliases
# Configure static SSH Agent # Configure static SSH Agent
export SSH_AUTH_SOCK=~/.spool/ssh-agent.sock export SSH_AUTH_SOCK=$HOME/.spool/ssh-agent.sock
if [ -e $SSH_AUTH_SOCK ]; then if [ -e $SSH_AUTH_SOCK ]; then
rm $SSH_AUTH_SOCK rm $SSH_AUTH_SOCK
fi fi
ssh-agent -a "$SSH_AUTH_SOCK" >/dev/null if [ -e $HOME/.spool/ssh-agent.env ]; then
rm $HOME/.spool/ssh-agent.env
fi
if [[ "`pgrep ssh-agent`" ]]; then
pkill ssh-agent
fi
. $HOME/scripts/ssh-agent.sh
# Static/predictable Sway socket # Static/predictable Sway socket
export SWAYSOCK=`sway --get-socketpath` export SWAYSOCK=`sway --get-socketpath`

View File

@ -2,8 +2,9 @@
if [ ! $SSH_TTY ]; then if [ ! $SSH_TTY ]; then
# Remove socket files # Remove socket files
rm SSH_AUTH_SOCK rm $SSH_AUTH_SOCK
rm SWAYSOCK rm $HOME/.spool/ssh-agent.env
rm $SWAYSOCK
fi fi
# when leaving the console clear the screen to increase privacy # when leaving the console clear the screen to increase privacy

View File

@ -93,6 +93,16 @@ export TERM="xterm"
echo -e -n "\033]2;Welcome to Bash\007" echo -e -n "\033]2;Welcome to Bash\007"
SSH_AUTH_SOCK="$HOME/.spool/ssh-agent.sock" SSH_AUTH_SOCK="$HOME/.spool/ssh-agent.sock"
if [ -z $SSH_AGENT_PID ]; then
if [ -f "$HOME/.spool/ssh-agent.env" ]; then
source $HOME/.spool/ssh-agent.env >/dev/null
else
if [ ! -f $SSH_AUTH_SOCK ]; then
touch $SSH_AUTH_SOCK
fi
$HOME/scripts/ssh-agent.sh
fi
fi
# Distrobox only # Distrobox only
if [ -f "/run/.containerenv" ]; then if [ -f "/run/.containerenv" ]; then