Last active
October 9, 2019 07:46
-
-
Save zouppen/2bc5ef53a90a94ebaaf1a2591101b9fe to your computer and use it in GitHub Desktop.
Show originating IP address and connection time of SSH tap device
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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