1

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 ?

hello world
  • 103
  • 2
  • 8

2 Answers2

0

If you're still looking for the answer. Most of the system files can be read by any user so if you simply run:

less /etc/ssh/sshd_config

you should be able to read the file. It should have something like Port 22, which is the port that SSH is listening on.

Port 22 is the default port for SSH, so if the line is commented (#Port 22), then its listening on Port 22 as well.

0

If you are using Tectia you can check ssh-server listening port using below command:

grep "port" < /etc/opt/SSHtectia/ssh-server-config.xml

If there are multiple ssh-server processes and each is listening on different port you can check for each process which port is listening using below command:

ps -ef | grep "ssh-server"