Friday, June 1, 2007

What do I do with my passwords?

Have you noticed the incredible number of services, emails, accounts, logins and identities we have to manage on a daily basis? I am sure you already have a technique to handle your ids and passwords. The one I chose is... keep all my information in a text file.

Of course it is not that simple ;-)

I do have a text file with all my ids and passwords though. I write it in a very human legible format (== no xml). You would read something like this if you got your hands on it

www.pizzapizza.com
marcelop/mypass
marcelop@the.email.I.used.here.com


This file is stored on my server, where I make all the changes, and duplicated on the machines I use. Given the importance of the data (to me at least), I decided that it would be wise to encrypt it. Enters ccrypt. This package is available on both Linux and Windows (through Cygwin), and provides a command line application (ccrypt) to encrypt text files and another (ccdecrypt) to do the opposite operation. It also includes 'ccat' that displays the content of the file after decrypting it in memory.

So how do I put everything together? When I need to add a new entry to the file, I ssh to my server and run cad, defined this way:

alias cad='ccdecrypt ~/personal/ids.txt.cpt &&
vi ~/personal/ids.txt &&
ccrypt ~/personal/ids.txt'


This command (1) decrypts the file 'ids.txt.cpt', (2) opens the plain text file using vi, and, after I am done editing it, (3) encrypts the 'ids.txt' file.

After editing the ids file, I return to the machine I am working on (this has started with an ssh, remember?) and run the psync command defined by the following alias

alias psync='scp -p lh:/home/marcelop/personal/ids* ~/personal'


which copies the file located on my server (the alias stands for "personal sync" and actually copies other files that I only edit on the server). After that, whenever I want to check an specific information, I run this alias on the local machine

alias cad='ccat ~/personal/ids.txt.cpt | grep -i -B 2 -A 5 '


So something like cad pizza would display 2 lines above the "pizzapizza" entry and 5 below. Adding this to the .bashrc

export GREP_OPTIONS='--color=auto'


makes it even better, since the word "pizza" would appear in red.

There you are. Seems like a lot of work, but it is actually quite simple. After using this technique for 2 years, it feels absolutely natural.

PS: 'cad' stands for "cadeado" (locker in Portuguese).

No comments: