Rants of a madman » Mounting truecrypt volume from script, without showing password in process list
Aug
27

I have an encrypted home dir, which is automatically decrypted upon login. (Linux, if you were in doubt). I want to mount a large truecrypt partition automatically when i log in.

I wrote a small script that mounts the truecrypt drive. I added to .bashrc (you could also use .profile i guess) that this script automount script is mounted upon login.

Heres the initial script

truecrypt -t -k "" --auto-mount=devices -p 'MySuperSecretPassword'

Storing the password inside the script isnt the problem (remember that homedir is already encrypted). The problem is, when doing “ps ax”, the password shows up in the list, as such:

3471 ? Ssl 0:00 truecrypt -t -k --auto-mount=devices -p MySuperSecretPassword

Bad idea.. I want to mount using a password and not a “keyfile”, but truecrypt doesn’t provide any other way of supplying a password.

However the solution was pretty simple, once i found it.


echo "MySuperSecretPassword" | truecrypt -t -k "" --auto-mount=devices -p ''

Its really a coincidence that this works. Truecrypt tries to mount using a blank password.. Once this fails, it will prompt for a password.. The prompt will be filled from the pipe.. And now password is gone from ps ax and im a happy camper.



  - Dan

Comments

  1. Jan van Tonder Said,

    Cool, thanks. Had the same issue.

  2. Jan van Tonder Said,

    Since I reliably need to mount the truecrypt volumes into the same folder I use the following:

    echo “”
    echo “Attempting to mount /dev/sdb as /media/truecrypt3″

    echo “$password” | /usr/bin/truecrypt -t -k “” –protect-hidden=no /dev/sdb /media/truecrypt3 -p ‘’

    if [ -f /media/truecrypt3/mounted.txt ]
    then
    echo “OK - /dev/sdb mounted in /media/truecrypt3″
    else
    echo “FAILURE - /dev/sdb could not be mounted”
    exit
    fi

Add A Comment

REFRESH THIS PAGE TO POST COMMENTS!