3 # 2019-08-23T00:36Z; baltakatei>
5 # This bash script should prompt the user for a URL, email address,
6 # user name, text notes, and then generate a password, push this
7 # password into the x clipboard, and then save a text file containing
8 # the prompted details. This script should be run by Debian-based
9 # GNU/Linux machines owned by baltakatei.
11 # This file by Steven Baltakatei Sandoval is licensed under CC BY-SA 4.0.
13 # Ask user for registration fields
14 echo "What is the URL for whose website you are registering? (omit https://)"
16 echo "input_URL is:"$input_URL
18 echo "What is your email address?"
20 echo "input_EMAIL is:"$input_EMAIL
22 echo "What is your user name (if any)?"
24 echo "input_USERNAME is:"$input_USERNAME
28 echo "input_NOTE is:"$input_NOTE
31 LONGDATE
=$
(date +%Y
%m
%dT
%H
%M
%S.
%N
%z
)
32 echo "Current time is:"$LONGDATE
36 echo "HOSTNAME is:"$HOSTNAME
38 # Perform superstitious PRNG spells
39 echo $LONGDATE$HOSTNAME > /dev
/random
40 echo $
(cat /proc
/sys
/kernel
/random
/entropy_avail
)" bits of entropy in /dev/random"
42 # Determine random 128-bit entropy password
43 PASS1
=$
(LC_ALL
=C
tr -dc "[:graph:]" < /dev
/urandom |
head -c ${1:-8})
44 PASS2
=$
(LC_ALL
=C
tr -dc "[:graph:]" < /dev
/urandom |
head -c ${1:-8})
45 PASS3
=$
(LC_ALL
=C
tr -dc "[:graph:]" < /dev
/urandom |
head -c ${1:-4})
46 PASSPHRASE
=$PASS1" "$PASS2" "$PASS3
47 echo "PASSPHRASE is:"$PASSPHRASE
49 # Print fields to temporary file
50 #echo "PASSPHRASE="$PASSPHRASE >> $PATHFILENAME
51 #echo "URL="$input_URL >> $PATHFILENAME
52 #echo "EMAIL="$input_EMAIL >> $PATHFILENAME
53 #echo "USERNAME="$input_USERNAME >> $PATHFILENAME
54 #echo "NOTE="$input_NOTE >> $PATHFILENAME
55 #echo "DATE="$LONGDATE >> $PATHFILE
57 # Push passphrase to clipboard
58 echo -n $PASSPHRASE | xclip
-selection clipboard
60 echo "Passphrase copied to clipboard via xclip."
62 # Push passphrase to `pass`
63 #printf "$PASSPHRASE\nURL=$input_URL\nEMAIL=$input_EMAIL\nUSERNAME=$input_USERNAME\nNOTE=$input_NOTE\nDATE=$LONGDATE\n" | pass insert -m 01\ Online\ Services/$input_URL
68 USERNAME=$input_USERNAME
71 " | pass insert
-m 01\ Online\ Services
/$input_URL