瀏覽代碼

Fix ssh-agent forwarding for tmux sessions

Kevin Heinicke 8 年之前
父節點
當前提交
1e8e4b7c8f
共有 2 個文件被更改,包括 5 次插入3 次删除
  1. 0 3
      tmux.conf
  2. 5 0
      zshrc

+ 0 - 3
tmux.conf

@@ -34,8 +34,5 @@ bind-key C-l send-keys C-l \; clear-history
 # Use vim keybindings in copy mode
 # Use vim keybindings in copy mode
 setw -g mode-keys vi
 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)
 # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
 run '~/.dotfiles/external/tpm/tpm'
 run '~/.dotfiles/external/tpm/tpm'

+ 5 - 0
zshrc

@@ -39,6 +39,11 @@ mounthome () {
  sshfs $1: /MountPoints/$1-home -o auto_cache,reconnect,volname=$1-home,no_readahead,noappledouble,nolocalcaches
  sshfs $1: /MountPoints/$1-home -o auto_cache,reconnect,volname=$1-home,no_readahead,noappledouble,nolocalcaches
 }
 }
 
 
+# use the symlinked ssh-auth-sock if available
+if [[ -f "$HOME/.ssh/ssh_auth_sock" ]]; then
+    export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock;
+fi
+
 # make the clipboard working on remote
 # make the clipboard working on remote
 if [[ -n "$SSH_CLIENT" ]]; then
 if [[ -n "$SSH_CLIENT" ]]; then
   SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')
   SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')