mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-03-02 22:57:00 -05:00
When monitoring SSH (tcp/22), the monitored server logs "key_exchange_identification" errors. #3439
Labels
No labels
A:accessibility
A:api
A:cert-expiry
A:core
A:dashboard
A:deployment
A:documentation
A:domain expiry
A:incidents
A:maintenance
A:metrics
A:monitor
A:notifications
A:reports
A:settings
A:status-page
A:ui/ux
A:user-management
Stale
ai-slop
blocked
blocked-upstream
bug
cannot-reproduce
dependencies
discussion
duplicate
feature-request
feature-request
good first issue
hacktoberfest
help
help wanted
house keeping
invalid
invalid-format
invalid-format
question
releaseblocker 🚨
security
spam
type:enhance-existing
type:new
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/uptime-kuma#3439
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @di-org on GitHub (Jun 29, 2024).
📑 I have found these related issues/pull requests
N/A
🛡️ Security Policy
Description
After setting up a "TCP Port" monitor for a hardened SSH service (tcp/22), every check is logged with an error for the key exchange, and though the service does show as up - it leaves behind a lot of log entries of connection errors:
---log---
Jun 29 20:30:53 ociph01 sshd[633660]: error: kex_exchange_identification: Connection closed by remote host
Jun 29 20:30:53 ociph01 sshd[633660]: Connection closed by 199.xxx.xxx.xxx port 52688
---log---
(to note, the masked IP is my Uptime-Kuma server host)
👟 Reproduction steps
Add the following lines to the monitored server's /etc/ssh/sshd_config file, and restart OpenSSH (My host is running Ubuntu 22.04):
Ciphers aes256-ctr
MACs hmac-sha2-512-etm@openssh.com
KexAlgorithms ecdh-sha2-nistp521
Monitor /var/log/auth.log for the error messages with the source IP of the Uptime-Kuma server. To note, the Key Exchange error does not have the IP of the offending host, but it is immediately followed by a "Connection closed" message from the source server.
👀 Expected behavior
There are a couple of options:
For #1, if I use a port scanner such as NMAP, when I test only to see if tcp/22 is open, there are no error messages logged because it doesn't attempt to negotiate SSH. I would expect uptime-kuma to only test if it returns a SYN-ACK, if it is looking to see of a port is open, and then send a FIN packet back to close the connection.
The alternative would be a full TCP handshake (if running as an unprivileged user), but still hang-up before an SSH negotiation occurs - standard practice for a port scanner (unless specifically testing functions that require negotiating the encryption protocols, such as bute-forcing, listing supported algorithms, authentication methods, etc).
For #2, if uptime-kuma is attempting things like cipher, KEX and MAC negotiations, it should be able to support all implemented encryption algorithms - in this case, the Key Exchange Algorithm "ecdh-sha2-nistp521".
😓 Actual Behavior
---log---
Jun 29 20:30:53 ociph01 sshd[633660]: error: kex_exchange_identification: Connection closed by remote host
Jun 29 20:30:53 ociph01 sshd[633660]: Connection closed by 199.xxx.xxx.xxx port 52688
---log---
(to note, the masked IP is my Uptime-Kuma server host, and otherwise is not making connections to TCP/22 to host "ociph01")
🐻 Uptime-Kuma Version
Version: 1.23.13
💻 Operating System and Arch
Ubuntu 22:04 x64
🌐 Browser
Librewolf 127.0.2-2
🖥️ Deployment Environment
📝 Relevant log output
No response
@CommanderStorm commented on GitHub (Jun 29, 2024):
I think I am missing something.
We are not doing a ssh keyexchange via the TCP Port monitor (nor should we).
=> the log is accurate that the connection is closed during that part.
For the behaviour: we are using https://www.npmjs.com/package/tcp-ping
You can try if #4806 changes this via https://github.com/louislam/uptime-kuma/wiki/Test-Pull-Requests