From 4674600a558e7783ba9c1fe2eec9380398219b8f Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Fri, 1 Jul 2022 14:24:48 +0200 Subject: [PATCH] ssh: ssh-agent eingebaut --- .bash_extra | 21 +++++++++++++++++++++ .ssh/config | 3 +++ 2 files changed, 24 insertions(+) diff --git a/.bash_extra b/.bash_extra index dc5ae4b..24debc8 100644 --- a/.bash_extra +++ b/.bash_extra @@ -4,6 +4,27 @@ if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then tmux attach -t default || tmux new -s default fi + +### ssh-agent +# https://rabexc.org/posts/pitfalls-of-ssh-agents +SSH_ENV="$HOME/.ssh/environment" +function start_agent { + echo "Initialising new SSH agent..." + (umask 066; /usr/bin/ssh-agent > "${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 + + ### PS1 # git-symbole: * unstaged, + staged, $ stashed, % untracked export GIT_PS1_SHOWUNTRACKEDFILES=1 diff --git a/.ssh/config b/.ssh/config index 806b432..796d1ab 100644 --- a/.ssh/config +++ b/.ssh/config @@ -1,3 +1,6 @@ +### ssh-agent +AddKeysToAgent yes + ### grote.lan Host dokuwiki2.grote.lan Host qmk.grote.lan