ssh-agent setup/teardown for host only

This commit is contained in:
John Mertz 2022-12-12 14:48:42 -05:00
parent df3583d9e5
commit f9031a775d
8 changed files with 39 additions and 44 deletions

View File

@ -5,22 +5,6 @@ systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT
# Load aliases # Load aliases
source ${HOME}/.dotfiles/bash/bash_aliases source ${HOME}/.dotfiles/bash/bash_aliases
# Configure static SSH Agent
export SSH_AUTH_SOCK=$HOME/.spool/ssh-agent.sock
if [ -e $SSH_AUTH_SOCK ]; then
rm $SSH_AUTH_SOCK
fi
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
export SWAYSOCK=`sway --get-socketpath`
export LANG="C" export LANG="C"
export LC_ALL="C" export LC_ALL="C"
export LC_CTYPE="C" export LC_CTYPE="C"

View File

@ -0,0 +1 @@
export SWAYSOCK="${HOME}/.spool/sway-ipc.sock"

View File

@ -0,0 +1,15 @@
# Configure static SSH Agent
export SSH_AUTH_SOCK=$HOME/.spool/ssh-agent.sock
if [ -e $SSH_AUTH_SOCK ]; then
rm $SSH_AUTH_SOCK
fi
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
export SWAYSOCK=`sway --get-socketpath`

View File

@ -1,17 +1,5 @@
# vim: ft=sh # vim: ft=sh
if [ ! $SSH_TTY ]; then
# Remove socket files
rm $SSH_AUTH_SOCK
rm $HOME/.spool/ssh-agent.env
rm $SWAYSOCK
fi
# when leaving the console clear the screen to increase privacy
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then
source $HOME/.dotfiles/bash/bash_logout.distrobox source $HOME/.dotfiles/bash/bash_logout.distrobox
else else

View File

@ -0,0 +1,11 @@
if [ ! $SSH_TTY ]; then
# Remove socket files
rm $SSH_AUTH_SOCK
rm $HOME/.spool/ssh-agent.env
rm $SWAYSOCK
fi
# when leaving the console clear the screen to increase privacy
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi

View File

@ -92,18 +92,6 @@ export TERM="xterm"
# Set initial title # Set initial title
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"
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
if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then if [ -f "/run/.containerenv" ] && grep -oP "(?<=name=\")[^\";]+" /run/.containerenv; then
source $HOME/.dotfiles/bash/bashrc.distrobox source $HOME/.dotfiles/bash/bashrc.distrobox
else else

View File

@ -0,0 +1,12 @@
export 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

View File

@ -5,10 +5,6 @@
# Background utilities # Background utilities
################################################################################ ################################################################################
# SSH Add - Should be started by profile instead
# exec eval `ssh-agent -a ${SSH_AUTH_SOCK}`
exec ssh-add &
# Automatically restore last used output configuration # Automatically restore last used output configuration
# TODO: Need to add fail-safe to script in case the outputs are unavailable # TODO: Need to add fail-safe to script in case the outputs are unavailable
exec $HOME/scripts/sway/displays.pl & exec $HOME/scripts/sway/displays.pl &