Getting list of opened ssh connections by name
- by lyrae
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