0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ssh先のtmuxでssh-agentの接続が切れてしまう問題の回避策まとめ

0
Posted at

方法1 .bashrc に書く

cat <<'EOF' >> .bashrc
[[ $SSH_AUTH_SOCK != $HOME/.ssh/sock && -S $SSH_AUTH_SOCK ]] \
    && ln -snf "$SSH_AUTH_SOCK" "$HOME/.ssh/sock" \
    && export SSH_AUTH_SOCK="$HOME/.ssh/sock"
EOF

出典
ssh先のtmuxでssh-agentの接続が切れてしまう問題の回避策 #SSH - Qiita

方法2 .ssh/rc と .ssh/config に書く

cat <<'EOF' > .ssh/rc
#!/bin/bash

# Fix SSH auth socket location so agent forwarding works within tmux/screen
if [ "$SSH_AUTH_SOCK" ]; then
  ln -sf $SSH_AUTH_SOCK ~/.ssh/agent.sock
fi
EOF

cat <<'EOF' >> .ssh/config
Host *
    IdentityAgent ~/.ssh/agent.sock
EOF

出典
screen で reattach しても ssh-agent が効き続けるようにする。 - There's an echo in my head

方法3 .ssh/rc と .tmux.conf に書く

cat <<'EOF' > .ssh/rc
#!/bin/bash

# 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
EOF

cat <<'EOF' >> .tmux.conf
# fix ssh agent when tmux is detached
setenv -g SSH_AUTH_SOCK $HOME/.ssh/ssh_auth_sock
EOF

出典
How to auto-update SSH agent environment variables when attaching to existing tmux sessions? - Stack Overflow

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?