How do I display all source and destination ssh sockets using network command ss?



  • Also see the man page: ss(8) - another utility to investigate sockets

    Display all source and destination ssh sockets.

    $ ss -a '( dport = :ssh or sport = :ssh )'
    Netid State   Recv-Q   Send-Q      Local Address:Port       Peer Address:Port
    tcp   LISTEN  0        128               0.0.0.0:ssh             0.0.0.0:*
    tcp   ESTAB   0        64          xx.xx.xx.xx:ssh      xx.xx.xx.xx:64716
    tcp   LISTEN  0        128                  [::]:ssh                [::]:*
    
           -a, --all
                  Display both listening and non-listening  (for  TCP  this  means
                  established connections) sockets.
    

    The port numbers can also be used.

    $ ss -a '( dport = :80 or sport = :80 )'
    Netid  State    Recv-Q   Send-Q      Local Address:Port     Peer Address:Port
    tcp    LISTEN   0        128               0.0.0.0:http          0.0.0.0:*
    tcp    LISTEN   0        128                  [::]:http             [::]:*
    

Log in to reply
 

© Lightnetics 2024