diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2025-02-16 16:21:29 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2025-02-16 16:21:29 -0500 |
| commit | c28246733dd163cc2298991948f0e71af2d458c5 (patch) | |
| tree | b30bd12686641017ed0ea3543b19c5fed612a27b | |
| parent | 8bbe8eddbfa33521646450013bf1b0de098d6819 (diff) | |
| download | dotfiles-c28246733dd163cc2298991948f0e71af2d458c5.tar.gz dotfiles-c28246733dd163cc2298991948f0e71af2d458c5.tar.xz | |
Add support for forwarded agents
| -rw-r--r-- | kshrc | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -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 |
