find out what programm wants to open a ssh session?

Avi Greenbury lists at
Mon Jul 8 14:54:31 UTC 2013

robert rottermann wrote:
> Hi there,
> on my Ubuntu 13.04 laptop I deleted all entries in .ssh/known_hosts.
> Since then, every couple of minutes I am asked that one of my remote
> hosts is not in known_hosts and whether it is OK to connect to it.

How are you asked? Could you get a screenshot so we can guess at which
agent is being invoked? :)

> Now I wonder what process would try to open a connection to that
> particular host.
> How can I find out what process that would be?

Personally, I'd open up a terminal and, while that pop-up is showing,
see what the output of 

    sudo netstat -ntp  | grep :22

is; netstat will print out a list of current connections, and the grep
will extract those involving port 22 (which ssh uses). For example,
this is four ssh sessions I have open to a total of three hosts:

    avi at fantastic:~$ sudo  netstat -ntp  | grep :2
    [sudo] password for avi: 
    tcp        0      0     ESTABLISHED 6560/ssh        
    tcp        0      0    ESTABLISHED 10039/ssh       
    tcp        0      0    ESTABLISHED 8758/ssh        
    tcp        0      0     ESTABLISHED 28952/ssh   

That line before the '/ssh' is the PID of the process with the
connection. You could grep `ps auxwww` for this. Or, perhaps, pipe
`pstree -A` into less and search for it - that way you can go back up
the process tree and see what invoked the SSH client.


More information about the ubuntu-users mailing list