[Discuss] Password app
Daniel Barrett
dbarrett at blazemonger.com
Fri Oct 10 12:59:24 EDT 2014
Here is my password app for Linux. It's free. :-)
1. Create a text file with three columns: username, password, and any
notes you want to add. Use a single tab character as a column separator.
2. Encrypt the file with GnuPG.
3. Write a script to run "gpg -d | grep -i" on your encrypted file to
locate matching lines. (So any command-line arg can be a search key.)
Use /usr/bin/cut to extract the first column and pipe it to "xclip
-selection clipboard", and the second column to "xclip -selection
primary".
4. Run the script with any arguments as search keys:
$ myscript amazon.com
5. Now, "right-click + Paste" will paste your username, and middle
mouse button will paste your password.
6. If you get tired of typing your passphrase over and over, use
gpg-agent or similar.
Here's my script, which also echoes the username and notes (third
column) on screen. Enjoy, modify, share, etc. Public domain.
------------8<----------------- cut here ----------------8<------------------
#!/bin/bash
if [ -z "$DISPLAY" ]
then
echo "$0: no DISPLAY, cannot use xclip"
exit 1
fi
PASSFILE=/path/to/your/file.gpg
lines=`gpg -d "$PASSFILE" | /bin/grep -i "$@"`
count=`echo "$lines" | wc -l`
echo
if [ $count -eq 1 ]
then
username=`echo -n "$lines" | cut -f1`
password=`echo -n "$lines" | cut -f2`
notes=`echo -n "$lines" | cut -f3`
echo "Username = $username"
echo "$notes"
echo "Password is in clipboard"
echo -n "$password" | xclip -selection primary
echo -n "$username" | xclip -selection clipboard
else
echo "$count lines found - multiple matches - try again"
fi
------------8<----------------- cut here ----------------8<------------------
--
Dan Barrett
dbarrett at blazemonger.com
More information about the Discuss
mailing list