Skip to content

Instantly share code, notes, and snippets.

@tsaavik
Last active June 4, 2026 15:53
Show Gist options
  • Select an option

  • Save tsaavik/c0512d2d2d138a45d0db45fc4c410277 to your computer and use it in GitHub Desktop.

Select an option

Save tsaavik/c0512d2d2d138a45d0db45fc4c410277 to your computer and use it in GitHub Desktop.
Are your long running ssh agent sockets failing? Perhaps something is cleaning /tmp? This rc file for ssh fixes all these problems.
# Fix ssh sockets in Tmux and Screen - dmcanulty 2021-2026 - https://gist.github.com/tsaavik/c0512d2d2d138a45d0db45fc4c410277
# After putting THIS file at ~/.ssh/rc add the following to your Tmux or Screen confs
# .tmux.conf - set-environment -g 'SSH_AUTH_SOCK' ~/.ssh/ssh_auth_sock
# .screenrc - setenv SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
# Now add the following to your ~/.ssh/config to prevent /tmp reapers from getting it
# Host *
# IdentityAgent ~/.ssh/ssh_auth_sock
# Multiple Putty sessions issues? Enable `connection->ssh->Share SSH connetions`
# This is the actual code. If symlink dosn't point at a socket and env variable is valid socket, make a symlink
if [ ! -S ~/.ssh/ssh_auth_sock ] && [ -S "$SSH_AUTH_SOCK" ]; then
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment