2

Using lsof -i I can see there is a reverse ssh tunnel set up on my server:

sshd       1321   remote    8u  IPv4 219299       TCP localhost.localdomain:mvs-capacity (LISTEN)

How can I find out the IP address of the machine that created this tunnel?

Thanks

5 Answers5

3

lsof -nPp 1321

al.
  • 925
  • 6
  • 17
1

Run lsof -i | grep 1321 to see the other connections the pid has, one of which should be the ip of the machine that created the tunnel.

Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
1

or you can use netstat -a

Zak
  • 1,032
  • 2
  • 15
  • 25
0

Try netstat -ntp | grep 1321 (replace 1321 with the pid of the process in question.). This will allow you to see the network connections.

knx
  • 111
  • 2
0

To get only the ip address you can do this.

netstat -ntp | grep "27750" | awk '{print $5}' | awk -F ':' '{print $1}'

If you know that you only have one tunnel you can use this without knowledge of the pid.

netstat -ntp | grep "sshd: root" | awk '{print $5}' | awk -F ':' '{print $1}'