Quiz Entry - updated: 2026.11.26
In the Compose entry for the honeypot, ports: - 2222:2222 is set. Which port do you connect to, and why does Cowrie use 2222 rather than 22?
You connect to port 2222 on the NSM VM: Docker publishes the container's port 2222 on the host's port 2222 (host:container). Cowrie listens on 2222 because it runs as an unprivileged user, and only root may bind ports below 1024.
A Compose port mapping reads HOST:CONTAINER. 2222:2222 means "forward connections to the host's port 2222 into the container's port 2222". The lab connects with:
ssh root@<NSM-VM-IP> -p 2222
Why not 22?
- Cowrie deliberately does not run as root. A honeypot is, by design, a program attackers interact with, so it should have as few privileges as possible. On Linux, binding ports below 1024 needs root (or a special capability), so Cowrie uses 2222.
- On the NSM VM, port 22 is already taken by the real SSH server used to administer the box.
In a production deployment you would move the real SSH elsewhere and expose the honeypot on port 22, using a mapping such as 22:2222 or a firewall redirect. Attackers scan port 22, not 2222.
Go deeper:
Cowrie: Installing, listening on port 22 — the supported ways to expose an unprivileged Cowrie on port 22, and why it refuses to run as root.
Docker: Port publishing and mapping — the
HOST:CONTAINERsyntax and what Docker sets up on the host.capabilities(7) man page —
CAP_NET_BIND_SERVICE, the rule that only privileged processes may bind ports below 1024.