Skip to content

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

Closed
@Whisprin

Description

@Whisprin
  • 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>: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions