An interactive and realistic SSH honeypot designed to capture and analyze intrusion attempts, while providing a web dashboard (via Flask) for log visualization.
- Project Overview
- Directory Structure
- Key Features
- Prerequisites
- Installation and Configuration
- Redirecting Port 22 to Port 2222
- Running the Project
- Usage Example
- Web Dashboard
- Security and Isolation
- Contributing
- License
This SSH honeypot aims to simulate a full Linux environment:
- A rich virtual filesystem containing sensitive files.
- An interactive shell supporting internal commands (
cd,ls,cat,cp,mv,mkdir,rm,rmdir,touch,echo, etc.), auto-completion (Tab), and pipeline handling. - An SSH server listening on a non-privileged port (default 2222).
- A web dashboard (Flask) to monitor intrusion attempts and executed commands in real time.
project-root/
├── src/
│ ├── honeypot.py # Main script (example)
│ ├── alert.log # Alert logs (exploits, brute force, etc.)
│ ├── auth.log # Authentication logs (login attempts)
│ ├── commands.log # Logs of commands executed by attackers
│ ├── server.key # Persistent SSH key (generated if missing)
│ ├── Makefile # Makefile (optional)
│ └── requirements.txt # List of Python dependencies
├── venv/ # Virtual environment (optional)
├── LICENSE
└── README.md # This file
Note: File names may vary depending on your setup. The key elements are the logs (auth.log, commands.log, alert.log), the honeypot script, and the SSH key (server.key), which can also be generated using ssh-keygen.
Note: The logs folder contains all log files when the honeypot is running over the SSH tunnel.
-
Virtual Linux Environment
- Realistic directory structure with
/etc,/home,/root,/var, etc. - “Sensitive” files (passwords, SQL dumps, private keys, etc.).
- Realistic directory structure with
-
Interactive Shell
- Internal commands:
ls,cd,cat,cp,mv,mkdir,rm,rmdir,touch,echo, etc. - Pipeline (
|) support and auto-completion (Tab).
- Internal commands:
-
SSH Server
- Based on Paramiko.
- Default listening port 2222 (configurable).
-
Web Dashboard
- Flask for real-time log display.
- Enhanced interface with Bootstrap.
-
Intrusion Detection
- Advanced logging in
auth.log,commands.log, andalert.log. - Brute force detection (
IntrusionDetector). - Detection of common exploits (SQL injection, XSS, RCE).
- Advanced logging in
- Python 3.8+
- pip (or pip3)
- iptables (for port redirection, Linux only)
-
Clone or Copy the Repository
git clone https://github.com/Amayes985-stack/Honeypot-SSH cd Honeypot-SSH/src -
Create a Virtual Environment (optional but recommended)
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Check SSH Key The script automatically checks for
server.key. If missing, it will generate one. Make sure permissions are correct:chmod 600 server.key
By default, the honeypot listens on port 2222. To expose it on port 22, follow these steps:
-
Enable IP Forwarding
sudo sysctl -w net.ipv4.ip_forward=1
To make it permanent:
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
-
Add Redirection Rule (iptables)
sudo iptables -t nat -A PREROUTING -p tcp --dport 22 -j REDIRECT --to-port 2222
-
Save Rules
sudo apt install iptables-persistent -y sudo netfilter-persistent save
-
Start the Honeypot
python3 honeypot.py
or
make honeypot
You will see:
SSH Honeypot active on port 2222 -
Start the Web Dashboard (Flask) The
honeypot.pyscript includes starting the dashboard (start_dashboard) as a daemon thread, default port 5000. Access it via:http://<your-ip>:5000
-
SSH Connection from an external machine:
ssh user@<your-server-IP> -p 22
(Traffic will be redirected from port 22 to 2222.)
-
Execute Commands: Attackers can run commands like
ls,cd /root,cat secrets.txt, etc. The honeypot logs all commands incommands.log. -
Check Logs:
auth.log: Login attempts (IP addresses, passwords tried).commands.log: Executed commands.alert.log: Detected suspicious activity (e.g., brute force, exploits).
The Flask dashboard, accessible at http://<your-ip>:5000, displays the 10 latest commands from commands.log:
- Time : Command timestamp.
- IP : Attacker’s IP address.
- Command : Exact command entered.
- Country : Origin country (via IP-API).
- Honeypot Isolation: Use a virtual machine or dedicated Docker container.
- Firewall: Block all unnecessary ports and monitor traffic to port 22.
- Active Monitoring: Regularly check logs (
auth.log,commands.log,alert.log) and the dashboard for suspicious activity. - Updates: Keep Kali Linux (or your distribution) updated and regularly check Python dependencies.
- Fork the repository.
- Create a new branch for your changes.
- Submit a Pull Request with your improvements.
Suggestions for new internal commands, auto-completion improvements, or exploit detection modules are especially welcome!
This project is licensed under the MIT License. See the LICENSE file for more details.
Contact:
- Author: Amayes DJERMOUNE
- Email: [amayes.djermoune2002@gmail.com]
- GitHub: https://github.com/Amayes985-stack/Honeypot-SSH