What's listening on your server? A five-minute inbound port audit
If you run your own VPS, every open port is a door someone on the internet can try. Most servers that host a web app only need two of them: 80 and 443. Here is a quick way to check what yours actually exposes, and the us
If you run your own VPS, every open port is a door someone on the internet can try. Most servers that host a web app only need two of them: 80 and 443. Here is a quick way to check what yours actually exposes, and the usual surprises.
1. List what is listening
On the server:
sudo ss -tulpn
Look at the local address column. 127.0.0.1:5432 is only reachable from the server itself. 0.0.0.0:5432 or [::]:5432 means every interface, so possibly the whole internet.
2. Check from the outside
Your firewall rules are what you intended. What matters is what answers. From another machine, scan your server's public address (only scan servers you own):
nmap -Pn your.server.ip
Anything here other than 80 and 443 deserves a reason.
3. The Docker gotcha
If you run docker run -p 5432:5432 postgres, Docker writes that rule straight into iptables. On many setups ufw does not filter it, so ufw deny 5432 can look right and still leave Postgres open.
Two fixes:
# bind the published port to localhost only
docker run -p 127.0.0.1:5432:5432 postgres
# or don't publish it at all; let the app reach it on a Docker network
docker network create appnet
docker run --network appnet --name db postgres
Then add a cloud firewall at your provider in front of the server, so a mistake on the box is not the only line of defence.
4. Ask what port 22 is for
SSH is often open because a deploy tool or CI job logs in to push releases. That means a private key with root-level reach lives somewhere outside your server: a CI secret, a laptop, a vendor's database. Worth asking where yours are, and who could use them.
How Unrent does it
We built Unrent so deploys don't need any of that. An agent on each server connects out to the control plane. It opens no port and has no listener, and Unrent never holds an SSH key, a password or a long-lived credential for your servers.
The agent only runs signed jobs with fixed schemas. There is no "run this command" job, and anything destructive also needs a passkey approval that the agent checks itself. An unknown job kind, a missing field or an expired signature means it refuses.
So from the internet, your apps answer on 80 and 443, and that is it. Databases are not published unless you turn on external access, and then only over TLS from networks you list.
The short version
Run ss -tulpn, scan yourself from outside, watch out for Docker-published ports, and ask why port 22 is open. If the answer is "my deploy tool", there is another way.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.