Skip to content

Instantly share code, notes, and snippets.

@jondlm
Created October 30, 2014 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jondlm/54be920e40f898c270a6 to your computer and use it in GitHub Desktop.
Save jondlm/54be920e40f898c270a6 to your computer and use it in GitHub Desktop.
SSH agent with tmux

Create a file called ~/.ssh/save_ssh_agent.sh on your remote box and make it executable:

#!/bin/sh
SSHVARS="SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION DISPLAY"

for var in ${SSHVARS} ; do
  echo "export $var=\"$(eval echo '$'$var)\""
done 1>$HOME/.ssh/latest_ssh_agent.sh
  1. ssh into your box using ssh agent forwarding.
  2. run ~/.ssh/save_ssh_agent.sh
  3. run tmux
  4. run ~/.ssh/latest_ssh_agent.sh
  5. run ssh-add -l to confirm that your keys are loaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment