Getting list of opened ssh connections by name
Posted
by
lyrae
on Server Fault
See other posts from Server Fault
or by lyrae
Published on 2012-09-22T23:20:28Z
Indexed on
2012/09/23
9:39 UTC
Read the original article
Hit count: 216
ssh
I have a config file in my .ssh dir that looks like this
Host somehostA
HostName 123.45.67.89
User katsh
So from my local machine, i can ssh into multiple machines by their name in the config file, like so
ssh somehostA
ssh somehostB
ssh somehostC
...
etc
Is it possible to get a list of all machines i am connected to, by their name?
I know I can do:
lsof -i tcp -n | grep '\<ssh\>'
and i'll get something like
ssh 9871 katsh 3u IPv4 400199 0t0 TCP 987.654.2.2:47329->987.654.2.2:47329:ssh (ESTABLISHED)
ssh 20554 katsh 3u IPv4 443965 0t0 TCP 123.456.7.8:41923->123.456.7.8:ssh (ESTABLISHED)
But it does not list their names, just IP
© Server Fault or respective owner