mirror of
https://gitea.com/gitea/docs.git
synced 2026-07-21 18:27:41 +00:00
Log IP on SSH authentication failure for Built-in SSH server (#13150)
* Log IP on SSH authentication failure fixes https://github.com/go-gitea/gitea/issues/13094 * include string 'Failed authentication attempt' in error * update fail2ban docs also match failed authentication over command line * better logging of authentication errors with IP addresses * format ... Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
@@ -20,18 +20,24 @@ sure to test this before relying on it so you don't lock yourself out.**
|
|||||||
|
|
||||||
Gitea returns an HTTP 200 for bad logins in the web logs, but if you have logging options on in
|
Gitea returns an HTTP 200 for bad logins in the web logs, but if you have logging options on in
|
||||||
`app.ini`, then you should be able to go off of `log/gitea.log`, which gives you something like this
|
`app.ini`, then you should be able to go off of `log/gitea.log`, which gives you something like this
|
||||||
on a bad authentication:
|
on a bad authentication from the web or CLI using SSH or HTTP respectively:
|
||||||
|
|
||||||
```log
|
```log
|
||||||
2018/04/26 18:15:54 [I] Failed authentication attempt for user from xxx.xxx.xxx.xxx
|
2018/04/26 18:15:54 [I] Failed authentication attempt for user from xxx.xxx.xxx.xxx
|
||||||
```
|
```
|
||||||
|
```log
|
||||||
|
2020/10/15 16:05:09 modules/ssh/ssh.go:188:publicKeyHandler() [E] SearchPublicKeyByContent: public key does not exist [id: 0] Failed authentication attempt from xxx.xxx.xxx.xxx
|
||||||
|
```
|
||||||
|
```log
|
||||||
|
2020/10/15 16:08:44 ...s/context/context.go:204:HandleText() [E] invalid credentials from xxx.xxx.xxx.xxx
|
||||||
|
```
|
||||||
|
|
||||||
Add our filter in `/etc/fail2ban/filter.d/gitea.conf`:
|
Add our filter in `/etc/fail2ban/filter.d/gitea.conf`:
|
||||||
|
|
||||||
```ini
|
```ini
|
||||||
# gitea.conf
|
# gitea.conf
|
||||||
[Definition]
|
[Definition]
|
||||||
failregex = .*Failed authentication attempt for .* from <HOST>
|
failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>
|
||||||
ignoreregex =
|
ignoreregex =
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user