3
############################################################################
4
# this script will read the /etc/passwd file and extract usernames
5
# that have one of the RESTRICTED_SHELLS. The ouput of this
6
# script is a list of these restricted usernames suitable for
7
# use in WORK_DIR/restricted-usernames
9
# such as: python restricted_from_passwd > $WORK_DIR/restricted-usernames
10
# where $WORK_DIR is your DenyHosts WORK_DIR parameter
12
############################################################################
14
RESTRICTED_SHELLS = ("/sbin/nologin",
18
from pwd import getpwall
23
for pw_tuple in passwd:
24
if pw_tuple[6] in RESTRICTED_SHELLS:
25
usernames.append(pw_tuple[0])
28
for username in usernames: