commit e454cd0aac5b013e644fda45818bb9621121d501 parent 947458ff666c7984f7a21e8222164fdc7a35ff04 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Sat, 2 Jun 2018 18:51:44 -0400 Auto start ssh-agent Diffstat:
M | links/.profile | | | 20 | ++++++++++++++++++++ |
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/links/.profile b/links/.profile @@ -5,6 +5,26 @@ export LANG=en_US.UTF-8 # shellcheck source=/dev/null [ -f ~/.secret_env_vars ] && . ~/.secret_env_vars +# Start ssh-agent if not already running +SSH_ENV="$HOME/.ssh/environment" +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 #### PATH AND MACHINE SPECIFIC CONFIGS