How to: ss - Seeing Ports Your Server Is Listening On
#### Why

Ports are how applications, services, and processes communicate with each other -- either locally within your server or with other devices on the network. When you have an application or service (like SSH or Apache) running on your server, they listen for requests on specific ports.

Obviously we don't want your server listening on ports we don't know about. We'll use `ss` to see all the ports that services are listening on. This will help us track down and stop rogue, potentially dangerous, services.

#### Goals

- find out non-localhost what ports are open and listening for connections

#### References

- https://www.reddit.com/r/linux/comments/arx7st/howtosecurealinuxserver_an_evolving_howto_guide/egrib6o/
- https://www.reddit.com/r/linux/comments/arx7st/howtosecurealinuxserver_an_evolving_howto_guide/egs1rev/
- https://www.tecmint.com/find-open-ports-in-linux/
- `man ss`

#### Steps

1. To see the all the ports listening for traffic:

    ``` bash
    sudo ss -lntup
    ```
    
    > ```
    > Netid  State      Recv-Q Send-Q     Local Address:Port     Peer Address:Port
    > udp    UNCONN     0      0                      *:68                  *:*        users:(("dhclient",pid=389,fd=6))
    > tcp    LISTEN     0      128                    *:22                  *:*        users:(("sshd",pid=4390,fd=3))
    > tcp    LISTEN     0      128                   :::22                 :::*        users:(("sshd",pid=4390,fd=4))
    > ```
    
    **Switch Explanations**:
    - `l` = display listening sockets
    - `n` = do not try to resolve service names
    - `t` = display TCP sockets
    - `u` = display UDP sockets
    - `p` = show process information

1. If you see anything suspicious, like a port you're not aware of or a process you don't know, investigate and remediate as necessary.

([Table of Contents](#table-of-contents))