pam_honeycreds(8)
π― pam_honeycreds(8) β the manual page, bestie edition
okay so real talk: this is pam_honeycreds, straight out of the System Manager's Manual, and it's genuinely one of the most iconic little PAM modules out there. we're gonna get into it π
β¨ NAME β¨
pam_honeycreds β it watches for certain passwords being tried at logon, and/or captures the passwords being tried. that's it, that's the whole vibe π
πΈ SYNOPSIS πΈ
pam_honeycreds.so [user=<username>] [file=<path to creds file>] [syslog] [logcreds] [deny|denyall] [fails] [prompt=<prompt>]
like, that's the shape of it. every piece is optional, mix and match, you got this π«Ά
π DESCRIPTION π
pam_honeycreds.so is a PAM (Pluggable Authentication Modules) module that literally justβ¦ watches for certain passwords being used. main character energy, but for auth π
so here's the deal: you keep a list of passwords, and that list can be stored either in cleartext or as a list of salted sha256 hashes. either one is fine, no judgement.
it can also log passwords that don't match any list β but it will NEVER log passwords that are in a list. instead it reports them by file and line. that's the whole safety thing, iykyk π₯
and it's not just logging! a script can be run when a password is matched. so you can go full automation gremlin.
what's it for, you ask? three whole vibes:
- "honey credentials" β fake passwords made available to catch malicious actors within an environment π―
- lists of common passwords β to detect bruteforcers π
- or to detect real passwords turning up where they shouldn't π
β¨ OPTIONS β¨
these are the PAM options that can be applied to configuration files in /etc/pam.d. slay, let's go through every single one, no skipping:
user=[user patterns]β comma separated list offnmatch(shell-style) patterns that identify users for whom this rule applies. to match all users, either leave this out, leave it blank, or explicitly set it touser=*. a'!'character at the start of the pattern allows inversion, so to match all users but root use:user=!root. you CAN mix usernames with and without a leading'!'in a user list, so for instanceuser=!billing,bill*would match all usernames starting withbillexcept forbilling. cute, right? π!user=[user patterns]β comma separated list offnmatch(shell-style) patterns that identify users for whom this rule DOES NOT APPLY. note that this is different from putting a!before a user in auser=list β using the!user=keyword means all listed users are ignored by this rule. you CANNOT MIXuser=and!user=in the same PAM entry, you must use one or the other to specify which users apply or don't. pick a lane bestie πhost=[host patterns]β comma separated list offnmatch(shell-style) patterns that identify hosts for which this rule applies. to match all hosts, either leave this out, leave it blank, or explicitly set it tohost=*. a'!'character at the start of the pattern allows inversion, so to match all hosts but 192.168.1.1 use:host=!192.168.1.1. β οΈ check whether your software is configured to supply host credentials to PAM as hostnames or IP addresses β fr fr, go check.!host=[host patterns]β comma separated list offnmatch(shell-style) patterns that identify hosts for which this rule DOES NOT APPLY. note that this is different from putting a!before a host in ahost=list β using the!host=keyword means all listed hosts are ignored by this rule. you CANNOT MIXhost=and!host=in the same PAM entry, you must use one or the other to specify which hosts apply or don't. and again, β οΈ check whether your software is configured to supply host credentials to PAM as hostnames or IP addresses.file=[path to creds file]β comma separated list of files in which to check for matching passwords. the file format is discussed below, keep reading π¦sfile=[path to file]β comma separated list of sorted files in which to check for matching passwords. these will be simple text files, one password per line, and alphabetically sorted so that a fast binary search can be used. speed, she's iconic βsyslogβ record events via syslog messages. you probably want to do this if you intend to "harvest" lists of passwords tried by your attackers, in which case you need to setlogcredstoo. teamwork!logcredsβ if this option appears, then passwords will be logged in syslog messages, but only if they do not appear in any of the file lists. if your own passwords appear in the list files (as sha256 salted hashes, of course). they will not be logged. remember, your log files could be compromised too, so you want to avoid revealing your passwords in them. π sincepam_honeycreds2.0,logcredsimpliessyslog.logfoundβ if this option appears, then passwords will be logged in syslog messages, EVEN IF THEY APPEAR IN FILE LISTS. this is a dangerous option β if someone gains access to your log files they could harvest your passwords. it is intended for use with lists of passwords that are not your real passwords, so you can detect password-guessing attempts. sincepam_honeycreds2.0,logfoundimpliessyslog. π please read that warning twice.ignore-blankβ ignore blank passwords. this option is intended for use with ssh systems that use a public/private key pair to log in. such logins create 'false positive' warnings, but can be ignored using this option. no more spam, blessed πscript=[path]β run script in the event of a match. arguments passed to the script will be "Event Type", "Matching File Entry" "User" "Host", where "Event Type" will beMatchorWrongUser, "Matching File Entry" will have the form[file path]:[line in file], "Host" will be the host from which the login has been attempted, and "User" will be the user that is being logged in. yes the arg order in that sentence is a little chaotic, we don't make the rules π«denyβ deny login if a password matches one of the file lists.failsβ log and run script for all passwords that are not in any list. this can be used to monitor particular account names for password-guessing activity. detective mode πdenyallβ deny all logins, whether a match is found or not. this is normally used against a user for whom we want to go through the authentication process, but whom we never wish to allow to log in. applications likesshdallow us to specify which users can log in, but users not in this list are not properly processed throughpam_honeycreds. thus we configuresshdto allow login by any user, but use thedenyalloption at thepam_honeycredslevel to block certain users from logging in at all. if adenyallrule has ascriptentry, then the script will be run for any event, even if no match is found within the credentials files. this allows triggering against some users (e.g.root) that should never login via some services (say,ssh). π big gun energy.
π heads up:pam_honeycredsshould appear in the pam module list after a module likepam_unix.so, so that the normal configured prompting proceedure is followed. order matters bestie, don't do it dirty.
π CREDENTIAL FILE CONFIG π
pam_honeycreds uses credentials files that contain one password per line. passwords containing spaces can be enclosed in quotes, or the spaces can be quoted with a \ (backslash) character. passwords can either be stored in plain-text (if they're fake) or as sha256 hashes of the password combined with a salt β the salt is simply prefixed to the password, and the resulting string is then hashed. π§β¨
the format of the password file is:
<password> [salt=<salt>] [user=<user>]
the user option is a comma-separated list of fnmatch patterns that match usernames who are allowed to use this password. this is used to raise an error if a user not in the list uses this password. snitch behaviour, honestly iconic π
π¦ SORTED FILES π¦
the 'sfile' option allows the use of a second type of file: a sorted file of unhashed one-password-per-line entries. this is useful for very large lists of common passwords (these are available online) that can be used to detect password guessing/bruteforcing attempts. big list, fast search, no cap πΈ
π₯ EXAMPLES π₯
an example PAM config file in /etc/pam.d might look like the example below. copy-paste responsibly π«Ά
#%PAM-1.0
auth include system-auth
auth required pam_honeycreds.so user=root syslog logcreds denyall file=/etc/mypasswords.conf
auth required pam_honeycreds.so user=!root syslog logcreds file=/etc/mypasswords.conf /etc/10-common-passwords.txt script=/usr/local/sbin/warn-admin.sh
auth required pam_honeycreds.so user=user* syslog fails file=/etc/honeycreds.conf script=/usr/local/sbin/honeycreds.sh
account required pam_nologin.so
account include system-auth
password include system-auth
session include system-auth
session required pam_loginuid.so
π SEE ALSO π
okay that's the whole page!! and for the cute sign-off: this edition is from 2015/05/15, part of the System Manager's Manual β so like, a little vintage, but she still ate. periodt ππ
π¦ where this page comes from
- nixpkgs unstable: pam-honeycreds 2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms