mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
28 lines
712 B
Bash
Executable File
28 lines
712 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Roughly based on this article:
|
|
# https://werat.github.io/2017/02/04/tmux-ssh-agent-forwarding.html
|
|
|
|
REMOTE_LINK="${HOME}/.ssh/ssh_auth_sock"
|
|
|
|
if [ "${1:-}" = "force" ] && [ -S "${SSH_AUTH_SOCK}" ] ; then
|
|
ln -sf "${SSH_AUTH_SOCK}" "${REMOTE_LINK}"
|
|
exit 0
|
|
fi
|
|
|
|
if test \! -S "${REMOTE_LINK}" -a -S "${SSH_AUTH_SOCK}" ; then
|
|
ln -sf "${SSH_AUTH_SOCK}" "${REMOTE_LINK}"
|
|
fi
|
|
|
|
# Handle X forwarding, per sshd(8)
|
|
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
|