Sample Header Ad - 728x90

find pid of open tcp port, as a regular user

3 votes
3 answers
1787 views
From local host I'm ssh tunneling some remote host:port to my local host:port, so anybody on a remote host can use their "local" port to access my port via that tunnel. I'm using some regular (non-root) user account on both hosts for this. For example: tunnelingdaemon from my localhost connect tunnelingdaemon@remotehost using ssh -R 127.0.0.1:2222:127.0.0.1:22 remotehost ... and opens port 2222 on remote host and connect it to port 22 on my local host. Root on remote host can use netstat, lsof, or fuser to find the PID of a process which opened and tunneled that port 2222. But regular user (tunnelingdaemon) cannot do that. For example >root: root@remote_host:/# fuser 2222/tcp 2222/tcp: 13709 root@remote_host:/# >tunnelingdaemon: tunnelingdaemon@remote_host:/$ fuser 2222/tcp tunnelingdaemon@remote_host:/$ On a remote host, **I can kill that process as a regular (tunnelingdaemon) user** under which is tunnel opened on the first place, but **I must be root to find which process I should kill**. That's a problem. I need to find a solution for this.
Asked by Goran (31 rep)
Nov 25, 2017, 09:16 AM
Last activity: Jul 8, 2020, 05:58 PM