You Can Waste an Attacker’s Time. You Probably Shouldn’t Bother.
An SSH tarpit is a fake SSH server that answers scanners very, very slowly and never lets them finish. Endlessh is the famous one. It is fun, it is cheap, and it protects nothing that key-only authentication does not already protect. Treat it as a toy with a telemetry side hustle, not a security control.
If you want data on who scans your IP, run endlessh-go in 2026, because it exports Prometheus metrics and has a Grafana dashboard. If you want a tiny package and no moving parts, apt install endlessh still works. If you want to be safe, turn off password logins first. Everything else on this page is optional.
Full example: Clone the working files at github.com/KingPin/sumguy-examples/security/endlessh-ssh-tarpit
How a Tarpit Wastes Time
RFC 4253 lets an SSH server send other lines of text before it sends its SSH-2.0- version string. Clients must handle those lines and may ignore them. Endlessh sends random lines forever, one at a time, with a delay between each. No key exchange happens. No crypto runs. The connection just sits there.
A scanner that sets no banner timeout hangs on that socket. Well-written scanners give up after a few seconds, so the tarpit catches the lazy ones. It cannot slow a human attacker, and it cannot slow anyone who already knows your real port.
Cost to you is close to zero. The C version holds each client as a small struct and a file descriptor, with one thread handling all of them. Your CPU barely notices.
Two Implementations, Different Jobs
| C Endlessh | endlessh-go | |
|---|---|---|
| Repo | skeeto/endlessh | shizunge/endlessh-go |
| Language | C, single thread, poll() | Go |
| License | Unlicense | GPL-3.0 |
| Default delay | 10000 ms | 1000 ms |
| Metrics | Text log only | Prometheus, Grafana dashboard |
| GeoIP | No | Optional |
| Maintenance | No release since 1.1 in early 2020 | Release 2026.0730.0 on 2026-07-31 |
| Install | apt install endlessh | Docker image or go build |
Both listen on port 2222 by default, both cap clients at 4096, and both send lines up to 32 characters. The one default that bites you is the delay. endlessh-go sends a line every second. The C version waits ten. If you want C-style slowness in the Go version, set -interval_ms=10000 yourself.
The C version counts as finished software. The last tag is 1.1 from January 2020, the repo got a push in June 2024, and it is not archived. A tarpit has a small job and the C version does that job. Do not expect new features. The GitHub “latest release” badge still points at 1.0 from April 2019, which confuses people who check it.
Running the C Version
Debian and Ubuntu ship it as a package:
sudo apt install endlesshsystemctl status endlesshThat gets you 1.1-5 on Debian 12 and 1.1-5.1 on Debian 13. The package ships no config file. Endlessh reads /etc/endlessh/config if you create it, using OpenSSH-style syntax:
Port 2222Delay 10000MaxLineLength 32MaxClients 4096LogLevel 1BindFamily 0LogLevel 0 is the default and logs almost nothing. Set it to 1 if you want to see connects and disconnects. BindFamily 0 means both IPv4 and IPv6. Most flags (-d, -l, -m, -p, -4, -6) mirror config keys, and argument order matters when you pass -f, so put it where the man page says.
Signals do the housekeeping. SIGTERM shuts down gracefully, SIGHUP reloads the config, and SIGUSR1 prints stats to the log (only with LogLevel 1 or higher, since level 0 prints nothing):
sudo systemctl kill -s SIGUSR1 endlesshsudo journalctl -u endlessh -n 20The Port 22 Gotcha
The packaged unit is upstream’s file with small packaging patches, and it sets PrivateUsers=true. That sandbox drops the daemon’s privileges, so it cannot bind below 1024 by default. Upstream’s recipe is three edits: setcap on the binary, uncomment AmbientCapabilities=CAP_NET_BIND_SERVICE, and comment out PrivateUsers=true. Editing the packaged unit gets overwritten on upgrade. A drop-in does not.
Check what your distro ships first. Ignore the [email protected] socket-activation tip in Debian’s README.Debian: the package ships no such socket unit.
systemctl cat endlesshsudo systemctl edit endlesshPut this in the editor:
[Service]AmbientCapabilities=CAP_NET_BIND_SERVICEPrivateUsers=falseThen change Port 2222 to Port 22 in the config and restart. Do not do that yet. Port 22 is still taken by your real sshd.
Running endlessh-go With Metrics
The Go version comes as a container, so port 22 is a port mapping instead of a capability dance. The compose file pins the image tag and keeps the metrics port on loopback:
services: endlessh: image: shizunge/endlessh-go:2026.0730.0 container_name: endlessh restart: unless-stopped command: - -logtostderr - -v=1 - -healthcheck_enabled - -prometheus_enabled - -prometheus_clean_unseen_seconds=86400 ports: - "22:2222" - "127.0.0.1:2112:2112"-logtostderr -v=1 together give you C-style connect and disconnect lines in docker compose logs. Keep -healthcheck_enabled in the list: a command: replaces the image’s default arguments, and without that flag the built-in health check fails and Docker marks the container unhealthy. -prometheus_enabled turns on the exporter at /metrics on port 2112. The old -enable_prometheus flag still parses but is deprecated.
The -prometheus_clean_unseen_seconds flag matters more than it looks. The default is 0, which keeps a time series for every IP forever. The internet has a lot of IPs. Setting a cutoff of a day keeps your Prometheus from slowly growing a label-cardinality problem.
Memory use is about 10 MB per the README, which is more than the C version and still a rounding error on any server running Docker.
Try it from another machine, using a documentation address as a stand-in for yours:
ssh -p 22 192.0.2.10curl -s http://127.0.0.1:2112/metrics | grep '^endlessh_'The ssh command should hang. That is the point.
What the Metrics Give You
Four counters show totals: endlessh_client_open_count_total, endlessh_client_closed_count_total, endlessh_sent_bytes_total, and endlessh_trapped_time_seconds_total. Two per-IP series carry labels: endlessh_client_open_count (labels ip, local_port, country, location, geohash) and endlessh_client_trapped_time_seconds (labels ip, local_port).
A few PromQL queries cover most curiosity:
# Connections trapped right nowsum(endlessh_client_open_count_total) - sum(endlessh_client_closed_count_total)
# New connections per hourincrease(endlessh_client_open_count_total[1h])
# Total attacker time wasted, in daysendlessh_trapped_time_seconds_total / 86400
# Top 10 longest-held IPstopk(10, endlessh_client_trapped_time_seconds)For a map and tables, import Grafana dashboard ID 15156. The README says it needs Grafana 8.2 or newer. A small Prometheus service for the compose file is in the example repo.
GeoIP Is Off by Default
Country and location labels stay empty until you pick a supplier with -geoip_supplier. The options are off, ip-api, and max-mind-db. The ip-api option calls a free web service that rate-limits and restricts commercial use. For a home lab that is fine. For anything with a company behind it, download a MaxMind database and pass -max_mind_db /path/to/file.mmdb.
Other flags worth knowing: -port can repeat to listen on several ports, -healthcheck_enabled serves 127.0.0.1:51000/health (the image already runs a health check every 30 seconds), and -proxy_protocol_enabled accepts PROXY protocol headers if a load balancer sits in front.
Move Your Real sshd First
You cannot run a tarpit on port 22 while sshd lives there. Either the tarpit stays on 2222 and catches almost nobody, or you move the real daemon. Moving it is the simplest way to make a tarpit useful, and it is also the step where people lock themselves out.
Follow the order:
- Open the firewall for the new port (say 2200) before anything else.
- Add the new port in
sshd_config. - Restart the right unit.
- Test from a second terminal while the first session stays open.
Port 2200sudo ufw allow 2200/tcpsudo sshd -tsudo systemctl restart ssh # sshd on RHEL-familyUbuntu 24.04 and later use socket activation, and ssh.socket owns the listening port. A systemd generator reads Port from sshd_config, so the change does nothing until you reload and restart the socket:
sudo systemctl daemon-reload && sudo systemctl restart ssh.socketOn RHEL-family systems, SELinux blocks sshd from binding unusual ports. Label the new one:
sudo semanage port -a -t ssh_port_t -p tcp 2200One more trap. If you publish port 22 from a container, the host sshd has to be off 22 before docker compose up, or the container will not start. Verify with sudo ss -tlnp | grep ':22 ' first.
What Protects You Instead
The tarpit does nothing about the actual risk, which is someone guessing a password or reusing a leaked one. A short list covers that risk, and none of it is exciting.
Moving sshd to 2200 adds no security. It cuts log noise because most bots only probe 22, and anyone who runs a full port scan still finds the new port.
These do the real work, in order of value:
- Key-only authentication. Bots guess passwords. If the server refuses passwords, every guess fails regardless of how many they send.
- Root login off. Same file, one line.
- A ban tool. fail2ban or CrowdSec drops repeat offenders at the firewall. That removes the log spam and the CPU spent on auth attempts. Our fail2ban vs CrowdSec comparison covers which one fits.
- Patching. The regreSSHion bug did not care about your password policy.
PasswordAuthentication noKbdInteractiveAuthentication noPermitRootLogin noPubkeyAuthentication yesMaxAuthTries 3Reload, then test a password login from a second machine. It should be refused with Permission denied (publickey). The SSH hardening guide goes deeper, and ed25519 keys are the sane default for key generation.
With those in place, a bot hitting your real sshd gets rejected in milliseconds. The tarpit would hold that bot for hours instead. Your server does not care either way. Both cases cost you nothing and risk nothing.
Does Tarpit Plus fail2ban Make Sense?
They coexist without conflict, because they listen on different ports. The tarpit sees connections that never authenticate, so a ban tool watching the SSH auth log never sees them. If your ban tool tails journalctl -u endlessh, it would ban people for being trapped, which is pointless since they are already stuck.
Leave the tarpit out of the banning tools’ log sources. Let it collect data, and watch the endlessh_client_open_count_total counter if you want to know whether a scan wave is in progress. Let fail2ban or CrowdSec guard the real daemon.
The Verdict
Run a tarpit if you like graphs and mild revenge. Run endlessh-go if you want those graphs, with GeoIP and a dashboard that takes ten minutes to import. Run the C version if you want a package from apt and one config file.
One practical note on the data. A count of scanners tells you the internet is noisy, which you already knew. It will not tell you whether anyone is targeting you in particular, so do not build alerts on it.
Skip it if you were hoping it would make your server safer. It will not. A forklift can move a couch, but nobody should buy one for that. The security work is five lines of sshd_config and a ban tool, and you should finish those before you spend an evening wiring up a Grafana panel of Lithuanian scanners.
Common Questions
Does Endlessh slow down my server?
No. C Endlessh serves every client from one thread with poll(), and each trapped client costs a small struct and a socket. endlessh-go uses about 10 MB of memory.
Does Endlessh stop a targeted attack?
No. A person who targets your server finds the real sshd port with a scan and ignores the tarpit. Endlessh only delays automated scanners that set no banner timeout. Key-only authentication and a patched sshd are what stop a targeted attacker, so set those up before anything else and treat the tarpit as optional.
Does Endlessh work with IPv6?
Yes. C Endlessh binds IPv4 and IPv6 together by default (BindFamily 0), and the -4 and -6 flags restrict it to one family. endlessh-go listens with Go’s tcp network on 0.0.0.0, which Go treats as all addresses, both families. Docker publishes 22:2222 on 0.0.0.0 and [::] by default. Confirm with sudo ss -tlnp | grep ':22 ' and look for a [::] line.
Which Docker image should I use for Endlessh?
Use shizunge/endlessh-go. The linuxserver/docker-endlessh image is archived on GitHub and gets no updates. C Endlessh has no official image, so on a bare host install the endlessh package from apt instead.
Can I run Endlessh and CrowdSec together?
Yes. Endlessh listens on the old port 22 and CrowdSec watches the auth log of the real sshd on its new port. The two never overlap. Do not point CrowdSec at the Endlessh log as an SSH source. Every trapped client would look like an attacker, which fills your ban list with addresses that were never going to get in anyway.