File: sshguard.8.rst

package info (click to toggle)
sshguard 2.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,468 kB
  • sloc: ansic: 3,871; sh: 2,471; lex: 345; yacc: 287; makefile: 95
file content (134 lines) | stat: -rw-r--r-- 4,838 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
.. Copyright (c) 2007,2008,2009,2010 Mij <mij@sshguard.net>

.. Permission to use, copy, modify, and distribute this software for any
.. purpose with or without fee is hereby granted, provided that the above
.. copyright notice and this permission notice appear in all copies.

.. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

========
sshguard
========

----------------------------------------------------
block brute-force attacks by aggregating system logs
----------------------------------------------------

:Date: January 1, 2025
:Manual group: SSHGuard Manual
:Manual section: 8
:Version: 2.5.1

SYNOPSIS
========
**sshguard** [**-hv**]
[**-a** *threshold*]
[**-b** *threshold*:*blacklist_file*]
[**-i** *pidfile*]
[**-p** *blocktime*]
[**-s** *detection_time*]
[**-w** *address* | *whitelist_file*]
[*file* ...]

DESCRIPTION
===========
**sshguard** protects hosts from brute-force attacks against SSH and other
services. It aggregates system logs and blocks repeat offenders using one of
several firewall backends.

**sshguard** can monitor log files and the standard output of running a shell
command. Log messages are parsed line-by-line for recognized attack patterns.
Attackers are blocked when enough attack patterns are detected in a
configurable time interval. Attackers are blocked temporarily but can also be
permanently blocked using the blacklist option.

**sshguard** must be configured before its first run. See
**sshguard-setup(7)**.

OPTIONS
=======
**-a** *threshold* (default 30)
    Each detected attack increases an attacker's attack score, usually by 10.
    Block attackers when their attack score exceeds *threshold*.

**-b** *threshold*:*blacklist_file*
    Blacklist an attacker when its attack score exceeds *threshold*.
    Blacklisted addresses are written to *blacklist-file* and never unblocked,
    even after restarting **sshguard**.

**-i** *pidfile*
    Write the PID of **sshguard** to *pidfile*. *pidfile* is removed when
    **sshguard** exits.

**-p** *blocktime* (default 120)
    Block first-time attackers for *blocktime* seconds. Subsequent blocks
    increase in duration by a factor of 2. Since **sshguard** unblocks
    attackers at random intervals, actual block times may be somewhat longer.

**-s** *detection_time* (default 1800)
    Reset an attacker's attack score after *detection_time* seconds since the
    last attack. This means that attackers who attack every *detection_time*
    seconds are never blocked by **sshguard**. However, an increased
    *detection_time* may have an impact on legitimate users.

[**-w** *address* | *whitelist_file*]
    Whitelist a single address, hostname, or address block given as
    *address*. This option can be given multiple times. Alternatively,
    provide an absolute path to a *whitelist_file* containing addresses to
    whitelist. See `WHITELISTING`_.

**-h**
    Print usage information and exit.

**-v**
    Print version information and exit.

ENVIRONMENT
===========
SSHGUARD_USER
    When set, sandboxed processes drop permissions by changing to this user.
    Normally set and overridden in *sshguard.conf* using the SSHGUARD_USER
    variable.

SSHGUARD_DEBUG
    Set to enable verbose output from **sshg-blocker**.

SSHGUARD_STATS_DIR
    When set, write Prometheus-compatible statistics to .prom files in this
    directory every minute. The STATS_DIR variable in *sshguard.conf* will set
    and override this environment variable.

FILES
=====
%PREFIX%/etc/sshguard.conf
    See sample configuration file.

WHITELISTING
============
Whitelisted addresses are never blocked. Addresses can be specified on the
command line or be stored in a file.

On the command line, give the **-w** option one or more times with an IP
address, CIDR address block, or hostname as an argument. Hostnames are
resolved once at startup. If a hostname resolves to multiple addresses, all
of them are whitelisted. For example::

    sshguard -w 192.168.1.10 -w 192.168.0.0/24 -w friend.example.com
        -w 2001:0db8:85a3:0000:0000:8a2e:0370:7334
        -w 2002:836b:4179::836b:0000/126

If the argument to **-w** begins with a forward slash ('/') or dot ('.'),
the argument is treated as the path to a whitelist file.

The whitelist file contains comments (lines beginning with '#'), addresses,
address blocks, or hostnames, one per line.

SEE ALSO
========
sshguard-setup(7)