sshtop
Report the top SSH brute-force sources and optionally block them
- Command:
/go/sshtop - Category: Security
- Required option: None
- Output: Table of the 20 most active sources (plus an email and WhatsApp alert when IPs are blocked)
- Last updated: 2026-11-19
On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also
Overview
/go/sshtop finds the IP addresses with the most failed SSH password attempts and, in block mode, blocks the persistent offenders. It:
- counts
Failed passwordentries per IP in/var/log/secure - lists the 20 busiest sources with their country, city, and company
- skips the server's own IPs and well-known search and CDN companies
- blocks any other IP with 100 or more failed attempts, using
block - sends an email and WhatsApp alert listing every IP it blocked
No setup is needed. GoAdmio's default cron jobs already run sshtop block every hour.
Quick start
# Show the top SSH brute-force sources (changes nothing)
/go/sshtop
# Show them and block every IP over the limit
/go/sshtop block
Syntax
/go/sshtop [block]
The command takes one optional argument and has no -- options. The limits are fixed in the script, as shown in Details.
Arguments
| Argument | Effect |
|---|---|
| (none) | Report only. Nothing is blocked and no alert is sent. |
block |
Report, then block each qualifying IP and send the alert. Takes the lock. |
underattack |
Takes the lock and reports, but never blocks. |
| Anything else | Treated like no argument: report only. |
Only the first argument is read.
Output
The command prints one table, sorted by failed attempts, highest first. It is printed in every mode, including block.
| Column | Meaning |
|---|---|
IP |
Source address of the failed logins. |
VISITS |
Number of Failed password lines from that IP in /var/log/secure. |
COUNTRY |
Country of the IP. |
CITY |
City of the IP. May be empty. |
COMPANY |
Owner or network name of the IP. |
Example (addresses are placeholders):
IP VISITS COUNTRY CITY COMPANY
203.0.113.45 1842 NL Amsterdam Example Hosting B.V.
198.51.100.7 377 US Dallas Sample Networks LLC
192.0.2.19 64 DE Frankfurt Demo Cloud GmbH
Alerts
When at least one IP is blocked, the command sends the same message by email and WhatsApp with /go/sendmail and /go/sendwhatsapp.
| Item | Value |
|---|---|
| Subject | Blocking SSH Brute Force Attacks (<N> IPs) |
| Body | A greeting, one line per blocked IP, a closing note, and a "do not reply" notice. |
| Line format | SSH Brute Force Attacks <IP> (<visits> Visits) - Country: <country>, Company: <company>. |
| Sent when | At least one IP was blocked in this run. |
Exit status
| Situation | Result |
|---|---|
| Normal run | Prints the table and exits. |
Another block or underattack run is active |
Prints Instance (<name>) already running. and exits with status 1. |
Examples
# See who is attacking SSH right now
/go/sshtop
# Block every source over the limit, as the hourly cron job does
/go/sshtop block
# Review the log of past runs
tail -n 20 /var/log/go/sshtop.log
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Instance (<name>) already running. |
A block or underattack run started in the last 60 seconds. |
Wait a minute, then run again. |
| The table is empty | No Failed password lines in /var/log/secure, for example after log rotation. |
Nothing to do. The count restarts with the new log file. |
| An IP is listed but not blocked | See When an IP is blocked. | Check each condition. |
Nothing is blocked when you run /go/sshtop |
Report mode never blocks. | Run /go/sshtop block. |
| No alert email or WhatsApp message | Alerts are sent only when an IP was blocked in that run. | Check block and the files in /var/log/go/block/. |
COUNTRY or CITY is empty or differs between runs |
From a terminal the values come from lookup functions. From cron they come from the whois record, which may have no city. | Run from a terminal for fuller results. |
| A legitimate IP was blocked | It exceeded 100 failed attempts. | Run unblock, and consider white. |
Details
When an IP is blocked
An IP is blocked only when every condition is true:
| # | Condition |
|---|---|
| 1 | The command was run with block. |
| 2 | The IP is one of the 20 with the most failed attempts. |
| 3 | The IP has 100 or more failed attempts. |
| 4 | The IP is not the server's own IPv4 or IPv6 address, or 127.0.0.1. |
| 5 | The company name does not contain google, bing, or cloudflare (see the note below). |
| 6 | No file named /var/log/go/block/<IP>.* exists, meaning it has not already been blocked. |
[!NOTE] The company check for
bingandcloudflarematch lowercase text only.
The block itself is done with /go/block <IP> ssh <country> <company>.
Fixed limits
| Setting | Value |
|---|---|
| Source log | /var/log/secure |
| Entries counted | Lines containing Failed password |
| IPs listed | 20 |
| Block threshold | 100 failed attempts |
| IP lookup services | checkip.amazonaws.com (IPv4) and icanhazip.com (IPv6), to identify the server's own addresses |
The counts cover only what is in the current /var/log/secure, so rotation resets them.
Locking
block and underattack runs share the lock file /usr/local/goadmio/lock/block.lock, which holds the name of the running command. If the file was modified within the last 60 seconds, the new run exits. An older lock is treated as stale and replaced. The lock is removed when the command exits.
Report-only runs do not use the lock.
Logging
Every run appends its arguments with a timestamp to /var/log/go/sshtop.log.
What a run does
flowchart TD
A["sshtop [block]"] --> B{"block or underattack?"}
B -- "Yes" --> C{"Lock younger than 60 s?"}
C -- "Yes" --> X["Exit: already running"]
C -- "No" --> D
B -- "No" --> D["Count Failed password lines per IP"]
D --> E["Take the top 20, skip own IPs"]
E --> F["Look up country, city, company"]
F --> G{"block mode, 100+ visits, not allowlisted, not already blocked?"}
G -- "Yes" --> H["Run block for the IP"]
G -- "No" --> I["Add row to table"]
H --> I
I --> J["Print table"]
J --> K{"Any IPs blocked?"}
K -- "Yes" --> L["Send email and WhatsApp alert"]
K -- "No" --> M["Remove lock, finish"]
L --> M
See also
| Command | Description |
|---|---|
block |
Block an IP address on a GoAdmio server |
unblock |
Unblock an IP address on a GoAdmio server |
white |
Add an IP to the whitelist |
fail2ban |
Install and configure Fail2ban to ban brute-force sources |
sasltop |
Report SASL LOGIN authentication failures and block persistent sources |
ssh |
Rewrite /etc/ssh/sshd_config with GoAdmio hardening |
port |
Change the default SSH port (22) to another port |
permitrootlogin |
Allow root SSH login from a specific IP |
cron |
Set up main cron jobs in GoAdmio |