Last active
January 20, 2016 13:33
-
-
Save tomkinsc/c2932097796155f4fd94 to your computer and use it in GitHub Desktop.
This prints the remote IP and local port of SSH reverse tunnels (ssh -R ...) , from the perspective of the machine NOT initiating the tunnel
This file contains 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/bash | |
# From: http://superuser.com/a/804660 | |
sudo lsof -i -n | egrep '\<sshd\>' | grep -v ":ssh" | grep LISTEN | sed 1~2d | awk '{ print $2}' | while read line; do sudo lsof -i -n | egrep $line | sed 3~3d | sed 's/.*->//' | sed 's/:......*(ESTABLISHED)//' | sed 's/.*://' | sed 's/(.*//' | sed 'N;s/\n/:/' 2>&1 ;done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment