How to Set Up an Open-Source Honeypot (Cowrie SSH/Telnet) Step by Step
A honeypot is a decoy system that exists only to be attacked. Any login attempt is suspicious by definition, which makes it one of the highest-signal detection tools you can run. This guide covers the concepts and a Cowrie install on Ubuntu.
Watch the community session
Our OSI Global session explains what a honeypot is, the different types, and walks through setting one up step by step (about 1 h 27 min).
▶Watch on YouTube: OSI Honeypot Step-by-Step Setup
Honeypot types in one minute
| Type | What it does | Examples |
|---|---|---|
| Low-interaction | Emulates a few services; safe and easy | OpenCanary, Dionaea |
| Medium-interaction | Fake shell that records commands and downloads | Cowrie (SSH/Telnet) |
| High-interaction | Real OS for attackers to use; rich data, higher risk | Instrumented VMs |
| Multi-honeypot platforms | Many sensors plus dashboards | T-Pot |
Safety first
- Run it on an isolated VM or cloud instance, never on a production server or a flat internal network.
- Move your real SSH to another port before exposing the honeypot on 22.
- Cowrie refuses to run as root. Use a dedicated user.
Step 1 — Move real SSH off port 22
sudo sed -i 's/^#\?Port 22$/Port 22222/' /etc/ssh/sshd_config
sudo systemctl restart ssh # reconnect with: ssh -p 22222 user@host
Step 2 — Install dependencies and a dedicated user
sudo apt update
sudo apt -y install python3-pip python3-venv libssl-dev libffi-dev build-essential libpython3-dev python3-minimal authbind
sudo adduser --disabled-password --gecos "" cowrie
sudo su - cowrie
Step 3 — Install Cowrie (pip method)
python3 -m venv cowrie-env
source cowrie-env/bin/activate
python -m pip install --upgrade pip
python -m pip install cowrie
mkdir ~/my-honeypot && cd ~/my-honeypot
cowrie init # creates etc/, var/ and a default config
cowrie start
Cowrie now listens on 2222/tcp (SSH) and, if enabled, 2223/tcp (Telnet).
Step 4 — Expose it on port 22
Redirect the standard port to Cowrie with one firewall rule (run as your admin user, not as cowrie):
sudo iptables -t nat -A PREROUTING -p tcp --dport 22 -j REDIRECT --to-port 2222
sudo apt -y install iptables-persistent && sudo netfilter-persistent save
Step 5 — Make it convincing
Edit ~/my-honeypot/etc/cowrie.cfg: set a realistic hostname, and adjust etc/userdb.txt to decide which username/password pairs "succeed".
Step 6 — Read what attackers do
tail -f ~/my-honeypot/var/log/cowrie/cowrie.json
You'll see login attempts, every command typed, and files attackers try to download (saved under var/lib/cowrie/downloads). Forward the JSON log to a SIEM (see our Wazuh guide) or use Cowrie's ELK, Splunk or SQL output plugins.
Keep it running
Use cowrie status, cowrie stop and cowrie start, or run it under systemd or supervisor so it restarts after a reboot. Upgrade with python -m pip install --upgrade cowrie inside the venv.