From c28246733dd163cc2298991948f0e71af2d458c5 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sun, 16 Feb 2025 16:21:29 -0500 Subject: Add support for forwarded agents --- kshrc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/kshrc b/kshrc index 1fa3ad1..9a6f773 100644 --- a/kshrc +++ b/kshrc @@ -1,4 +1,4 @@ -# Copyright 2024 Mitchell Riedstra +# Copyright 2025 Mitchell Riedstra # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -314,6 +314,23 @@ sshSetAskpass() { export SSH_ASKPASS_REQUIRE=force } +checkSSHAgentForward() { + if ! [ -d "$HOME"/.ssh ] ; then + mkdir -p "$HOME"/.ssh + chmod 600 "$HOME"/.ssh + fi + + if [ -z "$SSH_AGENT_PID" ] \ + && [ -n "$SSH_CONNECTION" ] \ + && [ -z "$TMUX" ] ; then + + echo "SSH_AUTH_SOCK=\"$SSH_AUTH_SOCK\"; export SSH_AUTH_SOCK" \ + > "$HOME"/.ssh/agent + elif [ -n "$TMUX" ]; then + . "$HOME"/.ssh/agent + fi +} + #shellcheck disable=SC2120 checkSSHAgent() { if [ "$1" = "-k" ] ; then -- cgit v1.2.3