Files
skel/dotfiles/ssh/rc
2020-11-06 09:35:45 -08:00

16 lines
386 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