Răsfoiți Sursa

try to reattach ssh agent to tmux

Kevin Heinicke 8 ani în urmă
părinte
comite
24cf4f8c9b
3 a modificat fișierele cu 25 adăugiri și 0 ștergeri
  1. 1 0
      install.conf.yaml
  2. 21 0
      sshrc
  3. 3 0
      tmux.conf

+ 1 - 0
install.conf.yaml

@@ -26,3 +26,4 @@
         relink: true
         path: external/prezto/
     /usr/local/bin/syncIgnore: scripts/syncIgnore
+    ~/.ssh/rc: sshrc

+ 21 - 0
sshrc

@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# based on/using http://stackoverflow.com/questions/21378569 and
+# https://gist.github.com/martijnvermaat/8070533
+
+# 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
+
+# Taken from the sshd(8) manpage.
+if read proto cookie && [ -n "$DISPLAY" ]; then
+    if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
+            # X11UseLocalhost=yes
+            echo add unix:`echo $DISPLAY |
+                cut -c11-` $proto $cookie
+    else
+            # X11UseLocalhost=no
+            echo add $DISPLAY $proto $cookie
+    fi | xauth -q -
+fi

+ 3 - 0
tmux.conf

@@ -17,5 +17,8 @@ bind-key C-l send-keys C-l \; clear-history
 # Use vim keybindings in copy mode
 setw -g mode-keys vi
 
+# reattach ssh agent
+setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
+
 # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
 run '~/.dotfiles/external/tpm/tpm'