Skip to content

Instantly share code, notes, and snippets.

@zouppen
Last active October 9, 2019 07:46
Show Gist options
  • Save zouppen/2bc5ef53a90a94ebaaf1a2591101b9fe to your computer and use it in GitHub Desktop.
Save zouppen/2bc5ef53a90a94ebaaf1a2591101b9fe to your computer and use it in GitHub Desktop.
Show originating IP address and connection time of SSH tap device
#!/bin/sh -eu
if test $# -ne 1; then
echo Usage: $0 TAP_DEVICE >&2
exit 2
fi
sidfile=`grep -slE "^iff:.*$1$" /proc/*/fdinfo/* | sed 's|[^/]*/[^/]*$|sessionid|'`
if test "$sidfile"; then
loginctl show-session -p Timestamp -p RemoteHost `cat $sidfile`
else
echo "No TAP device found: $1" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment