Add ssh-agent setup for pass-phrase protection

Gonna be using pass phrase ssh keys...
This commit is contained in:
Andrew Mulbrook 2021-08-19 13:27:33 -05:00
parent f31c077790
commit 240bb600f3
2 changed files with 34 additions and 1 deletions

View file

@ -31,3 +31,8 @@ if [ -d "$HOME/.scripts" ] ; then
PATH="$HOME/.scripts:$PATH"
fi
# Enable Ssh-Agent
if [ -n "$BASH_VERSION" ]; then
. "$HOME/.scripts/ssh_session"
fi

28
scripts/ssh_session Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
#
# setup ssh-agent
#
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi