To remove a given port bind the pid
can be found with sudo netstat -lnpt
and then removed with kill pid
. As the process name is known (sshd) the non sudoer user who started it may found the pid with :
$ ps --user user -o pid,comm | grep sshd
8543 sshd
And then kill it. So port bind removal can be easily automatized for a non sudoer user.
However if there are several port binds started by user, previous command will return several pids for several sshd
processes . If user needs to remove only one given port bind, it needs to find which pid is listening to that port.
Is this possible ?