A real-time SSH session watcher that monitors logins, detects anomalies, and alerts on suspicious activity.
This guide walks you through setting up a lightweight, SSH-enabled Docker container to simulate SSH activity for development or testing purposes.
docker run -d -P --name ssh-test rastasheep/ubuntu-sshd:latest
-d
– Run container in detached mode-P
– Map container’s ports to random ports on the host--name ssh-test
– Assign a name to the containerrastasheep/ubuntu-sshd:latest
– Lightweight SSH-enabled image
docker port ssh-test 22
- This shows the random host port mapped to the container’s port 22 (SSH).
Once you know the host port (say 49154
), connect using:
ssh root@localhost -p <port-number>
## Example:
ssh root@localhost -p 49154
The default root password is usually
root
(unless changed).
To check logs:
docker exec -it ssh-test bash
- Opens an interactive bash shell in the container.
Look for the authentication log:
cat /var/log/auth.log
If not found, follow the steps below to enable logging.
apt update
apt upgrade
apt update
– Fetches latest package infoapt upgrade
– Safely upgrades installed packages (skips if dependencies need to be added/removed)
To perform a full upgrade:
apt full-upgrade
apt install rsyslog -y
-y
– Automatically confirms all prompts
service rsyslog start
ps aux | grep rsyslog
ps
– Process snapshota
– Show processes for all usersu
– Show user who owns the processx
– Include processes not attached to a terminalgrep
– Pattern match forrsyslog
Using key-based authentication is:
- More secure than password-based login
- Ideal for scripting and automated testing
- Recommended for production-like simulations