Sshguard supports address whitelisting. Whitelisted addresses are not blocked even if they appear to generate attacks. This is useful for protecting lame LAN users (or external friendly users) from being incidentally blocked.

Whitelist addresses are controlled through the -w command-line option. This option can add explicit addresses, host names and address blocks.

Address whitelisting is only supported by sshguard branch 1.x. As of now, whitelisting is restricted to IPv4 addresses.

Whitelisting addresses

These are some examples for whitelisting plain (IPv4) addresses:

# specify one address straight:
# specify several addresses:
-w -w -w

Whitelisting host names

These are some examples for whitelisting hostnames:

# specify one host name straight:
# specify several different host names:
-w -w

When hosts resolve to multiple addresses, all of them are whitelisted. Hosts are resolved to addresses once, when sshguard starts up.

Whitelisting address blocks

Sets of IP addresses can be given in CIDR notation: network-address/mask. These are some examples for whitelisting in this form:

# whitelist addresses from to
# whitelist addresses PLUS to
-w -w

Whitelisting from files

In this form, the source of addresses information is not the command line options but a text file. This is useful when longer or more complex sets of addresses need to be whitelisted.

This is how such file appears:

# comment line (a '#' as very first character)
#   a single ip address
#   address blocks in CIDR notation
#   hostnames

Summing up, the format is the following:

  • line-based, one address set per line
  • lines beginning with '#' (sharp) are ignored
  • each address set can be expressed with the same format used for the command line argument: single address, host name or CIDR

Sshguard is told to whitelist address sets in file X with the following command line argument:

-w /full/path/to/X
It is distinguished from address, CIDRs and hostnames because the argument starts with a '/' (slash). Relative paths beginning with '.' (dot) are also supported.

Structured whitelisting

Finally, whitelisting can be composed by many of the proposed forms mixed together. This is an example:

# whitelist addresses in file /etc/friends + LAN + host
sshguard -w /etc/friends -w -w

Lates Releases View all»

  • Latest releases Latest releases are available from SourceForge. See 'News'.
  • sshguard 1.5 This is a milestone release, coming after 18 months ...
  • sshguard 1.5 Sshguard monitors services through their logging activity. It reacts ...

F.A.Q. View all»

  • What is sshguard?Sshguard is a small program that monitors services running on your machine from the log files. When it ...
  • Sshguard does not workYou have one of these problems: sshguard is not given logs correctly sshguard cannot run the commands for ...
  • What does sshguard do?The short version is: it receives log messages, it detects when a networked service has been abused based ...