aboutsummaryrefslogtreecommitdiff
path: root/kshrc
diff options
context:
space:
mode:
authorMitchell Riedstra <mitch@riedstra.dev>2025-02-16 16:21:29 -0500
committerMitchell Riedstra <mitch@riedstra.dev>2025-02-16 16:21:29 -0500
commitc28246733dd163cc2298991948f0e71af2d458c5 (patch)
treeb30bd12686641017ed0ea3543b19c5fed612a27b /kshrc
parent8bbe8eddbfa33521646450013bf1b0de098d6819 (diff)
downloaddotfiles-c28246733dd163cc2298991948f0e71af2d458c5.tar.gz
dotfiles-c28246733dd163cc2298991948f0e71af2d458c5.tar.xz
Add support for forwarded agents
Diffstat (limited to 'kshrc')
-rw-r--r--kshrc19
1 files changed, 18 insertions, 1 deletions
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