Hello, I have an ssh server running in daemon mode, I believe, so /etc/init.d/sshd stop wont work. I've tried finding this listening port with netstat (netstat -atx |grep 22) but there are too many processes to list. How do I find a pid using netstat? asked 11 May '10, 16:33 Jasper |
This should do the trick for you:
You'll get something like this:
The '17322' is the PID in this case. answered 11 May '10, 16:48 gregularexpr... add pipe: | perl -ne 'm,. (d+)/([^ ]+): ., && print "$1 $2'
(11 May '10, 20:30)
memnoch_proxy
True, or the below awk would work also (with sort and unique to weed out duplicates): netstat -anp | grep sshd | grep -v "::" | awk -F" " {'print $8'} | awk -F"/" {'print $1'} | sort | uniq
(11 May '10, 22:14)
gregularexpr...
|
As root, run:
you should receive something that looks like this: Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:37 0.0.0.0:* LISTEN 3425/inetd tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 3640/X tcp 0 0 0.0.0.0:113 0.0.0.0:* LISTEN 3425/inetd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 7586/sshd 0.0.0.0:* indicates port 22 is listening on all addresses. To search only for sshd, pipe netstat with grep:
answered 12 May '10, 07:11 Slug |
or
answered 12 May '10, 05:17 maszynista |
Please accept an answer, or provide more details so we can help.