usr.sbin/makefs/hammer2: Sync with recent userspace ondisk.c changes
[dragonfly.git] / usr.sbin / sshlockout / sshlockout.8
blob1a45397a7c89092ef54f3afbf95b7967cb1f9fbe
1 .\" Copyright (c) 2015 The DragonFly Project.  All rights reserved.
2 .\"
3 .\" This code is derived from software contributed to The DragonFly Project
4 .\" by Matthew Dillon <dillon@backplane.com>
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\"
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in
14 .\"    the documentation and/or other materials provided with the
15 .\"    distribution.
16 .\" 3. Neither the name of The DragonFly Project nor the names of its
17 .\"    contributors may be used to endorse or promote products derived
18 .\"    from this software without specific, prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
24 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" SUCH DAMAGE.
32 .\"
33 .Dd September 13, 2017
34 .Dt SSHLOCKOUT 8
35 .Os
36 .Sh NAME
37 .Nm sshlockout
38 .Nd utility to block port 22 on preauth failures
39 .Sh SYNOPSIS
40 .Bd -literal
42 # pf(4) configuration.
45 # in /etc/pf.conf
47 table <lockout> persist { }
49 # and later in /etc/pf.conf - see below
51 block in quick on $ext_if proto tcp from <lockout> to any port 22
53 # in /etc/syslog.conf
55 auth.info;authpriv.info          |exec /usr/sbin/sshlockout -pf "lockout"
57 # in root's crontab
59 3 3 * * *       pfctl -tlockout -T expire 86400
62 # ipfw(8) configuration.
64 ipfw table 0 create
65 ipfw add deny ip from '<0>' to any
67 # in /etc/syslog.conf
69 auth.info;authpriv.info         |exec /usr/sbin/sshlockout -ipfwtbl 0
71 # in root's crontab
73 3 3 * * *       ipfw -fq table 0 expire 86400
74 .Ed
75 .Sh DESCRIPTION
76 This program is generally installed in
77 .Pa /etc/syslog.conf
78 as a pipe to parse the
79 .Xr sshd 8
80 demons error log in realtime.
81 In addition, a root crontab entry should generally be created to clean
82 out stale entries in the
83 .Xr pf 4
85 .Xr ipfw 8
86 .Ar table
87 at least once a day.
88 Using expire instead of flush will maintain a rolling window of locked out
89 IPs.
90 The
91 .Xr pf 4
93 .Xr ipfw 8
94 module must be loaded and running with the table and rules properly
95 configured.
96 .Pp
97 This program will monitor the ssh syslog output and keep track of attempts
98 to login to unknown users as well as preauth failures.
99 If 5 attempts fail in any one hour period, a permanent entry is added to the
100 .Xr pf 4
102 .Xr ipfw 8
103 .Ar table
104 for the associated IP address.
105 You still have to add a rule to
106 .Xr pf.conf 5
107 or use
108 .Xr ipfw 8
109 to block IP addresses listed in this table.
110 The cron entry you create cleans the block list out typically once a day.
112 This program generally limits brute-force attempts to break into a machine
113 via ssh.
115 When setting up the
116 .Xr pf 4
118 .Xr ipfw 8
119 rules,
120 note that the table will be filled based on failed ssh connections destined
121 to that particular machine.
122 If the machine is acting as a router you can decide whether you want the
123 .Xr pf 4
125 .Xr ipfw 8
126 rule to lockout that suspect IP to just the machine,
127 or to everything it routes to.
128 We usually recommend an unconditional blocking rule.
129 .Sh NOTICE
130 This program is still a work in progress.
131 .Sh SEE ALSO
132 .Xr ssh 1 ,
133 .Xr pf 4 ,
134 .Xr syslog.conf 5 ,
135 .Xr ipfw 8 ,
136 .Xr sshd 8
137 .Sh HISTORY
140 utility first appeared in
141 .Dx 4.1 .
142 .Sh AUTHORS
143 .An Matthew Dillon Aq Mt dillon@backplane.com