From b74c1777b5757140f4d97f702098a91f73e8dc0c Mon Sep 17 00:00:00 2001 From: Scott Carroll Date: Sat, 3 May 2025 14:29:16 +0100 Subject: [PATCH] modify tmux and ssh to recover SSH_AUTH_SOCK after tmux reconnect --- base/.ssh/rc | 7 +++++++ base/.tmux.conf | 4 ++++ 2 files changed, 11 insertions(+) create mode 100644 base/.ssh/rc diff --git a/base/.ssh/rc b/base/.ssh/rc new file mode 100644 index 0000000..9369973 --- /dev/null +++ b/base/.ssh/rc @@ -0,0 +1,7 @@ +#!/bin/bash + +# Fix SSH auth socket location so agent forwarding works with tmux. +if test "$SSH_AUTH_SOCK" ; then + ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock +fi + diff --git a/base/.tmux.conf b/base/.tmux.conf index 7069783..44ffb56 100644 --- a/base/.tmux.conf +++ b/base/.tmux.conf @@ -21,3 +21,7 @@ if-shell -b '[ "$(echo "$TMUX_VERSION >= 3.3" | bc)" = 1 ]' { set-option -a terminal-features 'xterm-256color:RGB' set-option -sg escape-time 10 set-option -g focus-events on + +# fix ssh agent when tmux is detached +set -g update-environment -r +set-environment -g 'SSH_AUTH_SOCK' ~/.ssh/ssh_auth_sock