Built-in SSH Server: Log IP on failure #2774

Closed
opened 2025-11-02 04:48:04 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @Whisprin on GitHub (Jan 18, 2019).

  • Gitea version (or commit ref): 1.6.4
  • Git version: 2.20.1
  • Operating system: Linux
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

For the built-in ssh server: In case of an authentication / handshake error, can you please add the IP address to the log output of the error message? (similar to web interface authentication failures)
Currently the IP is logged with the authentication attempt only, but not with the auth failure.

Background: I'd like to configure fail2ban for the built-in ssh server similar to what's mentioned in the docs: https://docs.gitea.io/en-us/fail2ban-setup/

Currently a failed ssh connection logs like this:

Log

wrong public key

2019/01/19 00:30:21 [T] SSH: Handshaking for <remote_ip>:<port>
...
2019/01/19 00:31:04 [...a/modules/ssh/ssh.go:164 func1()] [E] SearchPublicKeyByContent: public key does not exist [id: 0]
2019/01/19 00:31:04 [...a/modules/ssh/ssh.go:140 func1()] [E] SSH: Error on handshaking: [ssh: no auth passed yet, public key does not exist [id: 0]]

no matching cipher

2019/01/19 00:28:18 [T] SSH: Handshaking for <remote_ip>:<port>
...
2019/01/19 00:28:18 [...a/modules/ssh/ssh.go:140 func1()] [E] SSH: Error on handshaking: ssh: no common algorithm for key exchange; client offered: [diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha1 diffie-hellman-group1-sha1], server offered: [curve25519-sha256@libssh.org]

Ideally the "[E] SSH: Error on handshaking: ..." would be something like:

[E] SSH: Error on handshaking with <remote_ip>:<port>: ...
Originally created by @Whisprin on GitHub (Jan 18, 2019). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.6.4 - Git version: 2.20.1 - Operating system: Linux - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description For the built-in ssh server: In case of an authentication / handshake error, can you please add the IP address to the log output of the error message? (similar to web interface authentication failures) Currently the IP is logged with the authentication *attempt* only, but not with the auth failure. Background: I'd like to configure fail2ban for the built-in ssh server similar to what's mentioned in the docs: https://docs.gitea.io/en-us/fail2ban-setup/ Currently a failed ssh connection logs like this: ## Log ### wrong public key ``` 2019/01/19 00:30:21 [T] SSH: Handshaking for <remote_ip>:<port> ... 2019/01/19 00:31:04 [...a/modules/ssh/ssh.go:164 func1()] [E] SearchPublicKeyByContent: public key does not exist [id: 0] 2019/01/19 00:31:04 [...a/modules/ssh/ssh.go:140 func1()] [E] SSH: Error on handshaking: [ssh: no auth passed yet, public key does not exist [id: 0]] ``` ### no matching cipher ``` 2019/01/19 00:28:18 [T] SSH: Handshaking for <remote_ip>:<port> ... 2019/01/19 00:28:18 [...a/modules/ssh/ssh.go:140 func1()] [E] SSH: Error on handshaking: ssh: no common algorithm for key exchange; client offered: [diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha1 diffie-hellman-group1-sha1], server offered: [curve25519-sha256@libssh.org] ``` Ideally the "[E] SSH: Error on handshaking: ..." would be something like: ``` [E] SSH: Error on handshaking with <remote_ip>:<port>: ... ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2774