You should open only limited ports for incoming and outgoing traffic on a server. You can use firewall like CSF firewall to open only trusted ports on a server.
If you want to check all open/listening ports that your server is using, run below command via SSH:
netstat -an
OR
netstat -tulp
OR
netstat -tulpn
The command will print a list of all open ports, protocol using the port, local address and foreign address (IP).