mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
Fix SSH agent forwarding clobbered by local agent in shenv
ssh/rc saves the raw forwarded socket in SSH_REMOTE_AUTH_SOCK before rewriting SSH_AUTH_SOCK to the stable symlink. shenv was ignoring that variable, so it saw SSH_AUTH_SOCK as "our link" and fell through to the systemd lookup, which could overwrite the symlink with a local agent socket and silently drop the forwarded one. Now shenv checks SSH_REMOTE_AUTH_SOCK first, giving forwarded sockets priority over any local agent. https://claude.ai/code/session_01RhXaFzxJA5D2BcGcz18ipA
This commit is contained in:
@@ -113,8 +113,12 @@ _is_link_path() {
|
||||
|
||||
_CANDIDATE=""
|
||||
|
||||
# 1. If current environment has a valid socket that is NOT our link, it's a prime candidate (e.g. SSH forwarding).
|
||||
if [ -S "${SSH_AUTH_SOCK:-}" ] && ! _is_link_path "${SSH_AUTH_SOCK}"; then
|
||||
# 1. Highest priority: ssh/rc sets SSH_REMOTE_AUTH_SOCK to the raw forwarded socket before
|
||||
# rewriting SSH_AUTH_SOCK to the stable symlink, so it survives the rewrite.
|
||||
if [ -S "${SSH_REMOTE_AUTH_SOCK:-}" ] && ! _is_link_path "${SSH_REMOTE_AUTH_SOCK}"; then
|
||||
_CANDIDATE="${SSH_REMOTE_AUTH_SOCK}"
|
||||
# If current environment has a valid socket that is NOT our link, it's a prime candidate (e.g. SSH forwarding).
|
||||
elif [ -S "${SSH_AUTH_SOCK:-}" ] && ! _is_link_path "${SSH_AUTH_SOCK}"; then
|
||||
_CANDIDATE="${SSH_AUTH_SOCK}"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user