OSI Global › Guides › Honeypot

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.

Level: Beginner–IntermediateTime: ~30 minutesCowrieUpdated Nov 2026

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).

OSI Honeypot Step-by-Step Setup — video thumbnail▶Watch on YouTube: OSI Honeypot Step-by-Step Setup

Honeypot types in one minute

TypeWhat it doesExamples
Low-interactionEmulates a few services; safe and easyOpenCanary, Dionaea
Medium-interactionFake shell that records commands and downloadsCowrie (SSH/Telnet)
High-interactionReal OS for attackers to use; rich data, higher riskInstrumented VMs
Multi-honeypot platformsMany sensors plus dashboardsT-Pot

Safety first

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.

Written by Dr. Vivek Khare — Author, Speaker, IT Leader with 25+ years of experience, ISO 27001 Lead Auditor and founder of OSI Global. Spotted something out of date? Tell us via the community form.