Skip to content

Commit

Permalink
Fixed reattached screen sessions not seeing the new SSH_AUTH_SOCK
Browse files Browse the repository at this point in the history
  • Loading branch information
agross committed Jan 5, 2016
1 parent 8bb4935 commit 8682e5a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions screen/screenrc.symlink
Expand Up @@ -14,3 +14,6 @@ termcapinfo xterm* ti@:te@

# Support updating the title bar from the screened shell.
termcapinfo xterm* 'hs:ts=\E]0;:fs=\007:ds=\E]0;\007'

# Use the SSH agent socket that is created by oh-my-zsh/plugins/ssh-agent.
setenv SSH_AUTH_SOCK /tmp/ssh-agent-$USER-screen
12 changes: 8 additions & 4 deletions ssh/postinit.zsh
Expand Up @@ -15,9 +15,13 @@ if [[ -n "$SSH_AGENT_PID" ]] && [[ -n "$SSH_AUTH_SOCK" ]]; then
setx SSH_AUTH_SOCK "$auth_sock" > /dev/null
unset auth_sock
else
verbose Removing system-wide export $fg[yellow]\$SSH_AGENT_PID$reset_color
setx SSH_AGENT_PID "" > /dev/null
if [[ -n "$SSH_AGENT_PID" ]]; then
verbose Removing system-wide export $fg[yellow]\$SSH_AGENT_PID$reset_color
setx SSH_AGENT_PID "" > /dev/null
fi

verbose Removing system-wide export $fg[yellow]\$SSH_AUTH_SOCK$reset_color
setx SSH_AUTH_SOCK "" > /dev/null
if [[ -n "$SSH_AGENT_SOCK" ]]; then
verbose Removing system-wide export $fg[yellow]\$SSH_AUTH_SOCK$reset_color
setx SSH_AUTH_SOCK "" > /dev/null
fi
fi
5 changes: 5 additions & 0 deletions ssh/zprofile.zsh
@@ -1,4 +1,9 @@
if [[ -n "$SSH_CONNECTION" ]] && (($+commands[screen])); then
if [[ -n "$SSH_AUTH_SOCK" ]]; then
verbose Symlinking $fg[yellow]$SSH_AUTH_SOCK$reset_color to $fg[yellow]/tmp/ssh-agent-$USER-screen$reset_color
ln -sf "$SSH_AUTH_SOCK" "/tmp/ssh-agent-$USER-screen"
fi

verbose Starting $fg[green]screen$reset_color because we\'re connected using $fg[green]ssh$reset_color
/usr/bin/screen -dRq ssh && exit
fi
3 changes: 3 additions & 0 deletions tmux/tmux.conf.symlink
Expand Up @@ -32,3 +32,6 @@ set -s escape-time 0

set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"

# Always copy SSH environment variables.
set -g update-environment "SSH_CLIENT SSH_CONNECTION SSH_TTY SSH_AUTH_SOCK SSH_ASKPASS"

0 comments on commit 8682e5a

Please sign in to comment.