Repository navigation
Remote host detect when connected by a remote client #549
Replies: 1 comment 3 replies
|
Good question! Part of this works today, and I'll add the rest. Seeing who is connected. Getting SSH_AUTH_SOCK from outside the client. When you #!/bin/sh
# Point ~/.ssh/agent.sock at the agent of the client that attached last.
link="$HOME/.ssh/agent.sock"
tuios subscribe --types client-session-changed | while read -r ev; do
[ "$(printf '%s' "$ev" | jq -r '.attached')" = true ] || continue
pid=$(printf '%s' "$ev" | jq -r '.pid')
sock=$(tr '\0' '\n' < "/proc/$pid/environ" 2>/dev/null | sed -n 's/^SSH_AUTH_SOCK=//p')
[ -S "$sock" ] && ln -sfn "$sock" "$link"
doneThen set A few caveats:
Enforcing a single client. There's no built-in way yet. tmux has |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Is it possible to detect on a remote host when there's an active connection from a client? I'm trying to figure out how I can dynamically change based on the connected clients. For example, on tmux I would enforce a single client and change SSH_AUTH_SOCK depending on whether connected locally or remotely.
Or alternatively, is there a way to get the SSH_AUTH_SOCK from outside the client?
All reactions