LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-03-2015, 07:57 AM   #1
yo8rxp
Member
 
Registered: Jul 2009
Location: Romania
Distribution: Ubuntu 10.04 Gnome 2
Posts: 102

Rep: Reputation: 31
Sshd PID IP return


Hi !
Some thing bothers me
Seems that scp /sftp sessions does show their respective PID under ps aux | grep ssh | grep notty

Code:
ps aux | grep sshd | grep notty
gabriel   6594  0.0  0.0  13104  1688 ?        S    15:39   0:00 sshd: gabriel@notty 
gabriel   6796  0.0  0.0  13248  1824 ?        S    15:52   0:00 sshd: gabriel@notty
So far so good , but say, in order to kill PID associated with specific IP address , i have to look into netstat to look for that PID , unfortunateley the PID reported by ps does not show under netstat ,

Code:
Desktop gabriel # netstat -a | grep 6594
Desktop gabriel # netstat -a | grep 6796
Desktop gabriel #
and without IP versus PID i could blindly kill sshd processes

How do i do that ?

..please do not reply with the big question "why ?"
 
Old 01-03-2015, 09:14 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
lsof | grep sshd | grep ESTAB
?
 
1 members found this post helpful.
Old 01-03-2015, 09:37 AM   #3
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,374

Rep: Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754Reputation: 2754
Have you tried 'netstat -atnp' or 'ss -atnp'?
 
Old 01-03-2015, 05:19 PM   #4
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
notty means there is no terminal, something like sftp.

Code:
lsof | awk '$2 == PID {print}' | grep TCP
NOTE: You need to run the command as root.

Last edited by robertjinx; 01-03-2015 at 05:21 PM.
 
1 members found this post helpful.
Old 01-04-2015, 01:36 AM   #5
yo8rxp
Member
 
Registered: Jul 2009
Location: Romania
Distribution: Ubuntu 10.04 Gnome 2
Posts: 102

Original Poster
Rep: Reputation: 31
thanks everyone !

Unfortunateley , none of the above does work , decided to create users for each device (tablet 1 to 10 , mobile, so on) , in this way it is a simple matter to kill -9 sshd sessions opened by android sshfs individualy without blind killing all sshd PID's

Quote:
gabriel@Desktop ~ $ ps aux | grep gabriel-mobile | grep notty
gabriel+ 3329 0.0 0.0 13204 1804 ? S 09:23 0:00 sshd: gabriel-mobile@notty
gabriel@Desktop ~ $
Quote:
Desktop gabriel # kill -9 3329
Desktop gabriel # ps aux | grep notty | grep gabriel-mobile
Desktop gabriel #

I would still like to use same user on multiple devices, and somehow to get the relevance within sshd PID and IP address
If anyone comes with another ideea , please post it here as it is not marked as "Solved"

Last edited by yo8rxp; 01-04-2015 at 01:56 AM.
 
Old 01-04-2015, 09:27 AM   #6
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
Doesn't look like you even tried:

Code:
lsof | awk '$2 == PID {print}' | grep TCP
 
1 members found this post helpful.
Old 01-04-2015, 09:38 AM   #7
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
This idea is a bit better:

Code:
lsof -n |awk '$2 == 11306 && $8 == "TCP" {print $9}'
11306 is the pid of one of the sftp processes:

Code:
root     11306  8665  0 16:35 ?        00:00:00 sshd: robert@notty
 
1 members found this post helpful.
Old 01-04-2015, 09:46 AM   #8
yo8rxp
Member
 
Registered: Jul 2009
Location: Romania
Distribution: Ubuntu 10.04 Gnome 2
Posts: 102

Original Poster
Rep: Reputation: 31
Damn ! , using ftp proto on android phone instead of ssh and I was searching for ssh , damn mistake ,,,blushing here LOL

Thank you robertjinx for busting the brain out !
Sincerely, Gabriel

Last edited by yo8rxp; 01-04-2015 at 10:10 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Confluence PID issue. (Removing/clearing stale PID file) vignesh4sh Linux - Server 5 12-05-2012 07:14 AM
sshd not creating PID file [CentOS5] neocookie Linux - Server 4 12-17-2008 07:36 AM
Starting sshd: /etc/init.d/sshd: line 113: /usr/sbin/sshd: Permission denied sumanc Linux - Server 5 03-28-2008 04:59 AM
How can I find my sshd pid on connect? Termina Linux - Networking 2 12-05-2006 07:30 PM
sshd at startup and pid questions :) breakerfall Linux - General 4 09-28-2003 08:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration