From 7ed3d3dcc89592e7448f0ff3a96691b44a046b33 Mon Sep 17 00:00:00 2001 From: Hans Goor Date: Mon, 18 Nov 2024 17:24:33 +0100 Subject: [PATCH] Update SSH config to automatically add keys to agent. Update ZSH config to automatically start the SSH agent. --- stowers/ssh/dot-ssh/config | 8 ++++++++ stowers/zsh/dot-zshrc | 1 + stowers/zsh/dot-zshrc.d/02-ssh-agent.sh | 11 ++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/stowers/ssh/dot-ssh/config b/stowers/ssh/dot-ssh/config index b0ec006..300ea3d 100644 --- a/stowers/ssh/dot-ssh/config +++ b/stowers/ssh/dot-ssh/config @@ -1,3 +1,11 @@ +# +AddKeysToAgent yes +UseKeychain yes + +Host localhost + UserKnownHostsFile /dev/null + StrictHostKeyChecking no + ## --- Jupiter --- # -- Physical servers -- Host jupiter-thebe-local diff --git a/stowers/zsh/dot-zshrc b/stowers/zsh/dot-zshrc index b4e2a3e..ffeebf5 100644 --- a/stowers/zsh/dot-zshrc +++ b/stowers/zsh/dot-zshrc @@ -1,5 +1,6 @@ # If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:/usr/local/bin:$PATH +export PATH="${PATH}:${HOME}/.local/bin" # Path to your oh-my-zsh installation. export ZSH="$HOME/.oh-my-zsh" diff --git a/stowers/zsh/dot-zshrc.d/02-ssh-agent.sh b/stowers/zsh/dot-zshrc.d/02-ssh-agent.sh index 99fafd9..586c487 100644 --- a/stowers/zsh/dot-zshrc.d/02-ssh-agent.sh +++ b/stowers/zsh/dot-zshrc.d/02-ssh-agent.sh @@ -1,3 +1,12 @@ #!/bin/bash -export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket" +if [[ -z "${SSH_CONNECTION}" ]]; then + if ! pgrep -u "$USER" ssh-agent >/dev/null; then + ssh-agent > "$TMPDIR/ssh-agent.env" + fi + + if [[ ! -f "${SSH_AUTH_SOCK}" ]]; then + source "$TMPDIR/ssh-agent.env" >/dev/null + fi +fi +