forked from vab/sysadmin-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenpasswds.sh
More file actions
executable file
·60 lines (49 loc) · 1.58 KB
/
genpasswds.sh
File metadata and controls
executable file
·60 lines (49 loc) · 1.58 KB
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
#!/bin/bash
# Server Pseudo-random Password Generation Script
# Author: V. Alex Brennen <vab@mit.edu>
# License: This script is public domain
# Date: 2012-02-26
# Description: This script will use the passgen password candidate generator
# to generate password candidates for a list of servers passed
# to it. The list server should be in a new line separated text
# file.
# Dependency: http://cryptnet.net/fsp/passgen/
PASSGEN=/usr/bin/passgen
PASSGEN_ARGS="-C -n 1 -u"
# Passgen program arguments (See passgen man page for more information)
# -a Alpha numeric characters only.
# -A Alphabetic characters only.
# -C Suppress config file not found messages.
# -H Homoglyph suppression level (0-2).
# -l The length of the password.
# -L For any letters, use lowercase only.
# -n Number of passwords to provide.
# -N Numeric characters only.
# -r Use /dev/random for password generation.
# -s Exclude the space character.
# -u Use /dev/urandom rather than /dev/random.
# (Will speed password generation)
# -U For any letters, user uppercase only.
# Function to generate and print a password candidate
function genpass
{
CANDIDATE=`$PASSGEN $PASSGEN_ARGS`
echo " root: $CANDIDATE"
}
# Test for a server list file argument
if [ -z "$1" ]; then
echo "Usage: $0 <server_list.txt>"
exit
fi
# Make sure the server list file is valid and readable
if [ ! -r "$1" ]; then
echo "Error: Could not open and read server list file: $1."
exit
fi
# Step through the list of servers, generating a new password for each one
for SERVER in $(cat $1);
do
echo $SERVER
genpass
done
exit