ssh session and port forward or reverse port matching or assocation howto

Use netstat with the -anpe option.  The e option shows the inodes and I do not know if it will always work or if it was by fluke but I was dealing with dozens of SSH sessions and needed to know which session was related to which forward (the PIDs of the SSH and SSHD did not match etc...)

Notice the "59560675" and "59560762" those are almost identical, if you find two sets that are nearly identical except for the last 3 digits they may match (in my case they need and all the other sessions seemed to be like this too, close by inode number)

netstat  -anpe

tcp        0      0 ::ffff:92.15.15.5:443    ::ffff:50.14.16.19:33356 ESTABLISHED 0          59560675   10198/sshd: audi
tcp        0      0 127.0.0.1:50003             0.0.0.0:*                   LISTEN      500        59560762   11767/sshd: audi

 

Obvously the above way is cumbersome and maybe was a fluke or won't work but it worked in my case.  I would still like to know if there is a better or proper way of tracking/mapping SSH sessions to port forwards.


Tags:

ssh, matching, assocation, howtouse, netstat, anpe, inodes, fluke, dozens, sessions, pids, sshd, etc, quot, identical, digits, inode, tcp, ffff, established, audi, obvously, cumbersome, mapping, forwards,

Latest Articles

  • Convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/413. convert-im6.q16: no images defined `pts-time.jpg' @ error/convert.c/ConvertImageCommand/3258. solution ImageMagick P
  • Apache PHP sending expires header solution cannot use cache with CDN
  • How to install virt-manager in Mint 22/Ubuntu 22
  • Infiniband Guide
  • python mysql install error: /bin/sh: 1: mysql_config: not found /bin/sh: 1: mariadb_config: not found /bin/sh: 1: mysql_config: not found mysql_config --version
  • FreePBX 17 How To Add a Trunk
  • Docker Container Onboot Policy - How to make sure a container is always running
  • FreePBX 17 How To Add Phones / Extensions and Register
  • Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes. solution
  • Cisco How To Use a Third Party SIP Phone (eg. Avaya, 3CX)
  • Cisco Unified Communication Manager (CUCM) - How To Add Phones
  • pptp / pptpd not working in DD-WRT iptables / router
  • systemd-journald high memory usage solution
  • How to Install FreePBX 17 in Linux Debian Ubuntu Mint Guide
  • How To Install Cisco's CUCM (Cisco Unified Communication Manager) 12 Guide
  • Linux Ubuntu Redhat How To Extract Images from PDF
  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format