Skip to content

Instantly share code, notes, and snippets.

@kennedyj
Last active December 20, 2015 10:20
Show Gist options
  • Select an option

  • Save kennedyj/6115244 to your computer and use it in GitHub Desktop.

Select an option

Save kennedyj/6115244 to your computer and use it in GitHub Desktop.
Use true crypt for GPG and SSH keys
#!/bin/bash
# This should be loaded into the user profile
export TRUECRYPT_COMMAND='/Applications/TrueCrypt.app/Contents/MacOS/Truecrypt --text'
export TRUECRYPT_VOLUME_PATH=$HOME/secrets.tc
if [ -e "/Applications/TrueCrypt.app/Contents/MacOS/Truecrypt" ]
then
alias crypt='$TRUECRYPT_COMMAND'
complete -W "mount umount" crypt_secrets
function crypt_secrets {
mount_point="$HOME/.mausoleum"
command=$1
if [ -z $command ] || [ "$command" == "mount" ]
then
$TRUECRYPT_COMMAND $TRUECRYPT_VOLUME_PATH $mount_point
elif [ "$command" == "umount" ]
then
$TRUECRYPT_COMMAND -d $TRUECRYPT_VOLUME_PATH
fi
}
fi
#!/bin/bash
# example prompt to display ☢ when the volume is mounted.
COLOR_DARK_GREEN="\[\033[1;36m\]"
COLOR_LIGHT_BLUE="\[\033[1;34m\]"
COLOR_NONE="\[\033[0m\]"
prompt_mausoleum() {
crypt_mount_count=$(crypt -l 2> /dev/null | grep \.mausoleum | wc -l | awk '{print $1}')
if [ $crypt_mount_count -gt 0 ]
then
# radioactive == \xe2\x98\xa2
echo -e "$COLOR_DARK_GREEN\xe2\x98\xa2$COLOR_NONE:"
fi
}
PROMPT_COMMAND='PS1="$(prompt_mausoleum)$COLOR_LIGHT_BLUE\w$COLOR_NONE: $";'
#!/bin/bash
function error_exit {
echo "ERROR: $1"
exit 1
}
TRUECRYPT_VOLUME_PATH=$HOME/secrets.tc
## check dependencies
if [ ! -e "/Applications/TrueCrypt.app/Contents/MacOS/Truecrypt" ]
then
error_exit "Truecrypt must be installed"
fi
if [ ! -e "$TRUECRYPT_VOLUME_PATH" ]
then
error_exit "Truecrypt volume must exist to continue"
fi
# get truecrypt volume ready
mkdir $HOME/.mausoleum
/Applications/TrueCrypt.app/Contents/MacOS/Truecrypt --text $TRUECRYPT_VOLUME_PATH $HOME/.mausoleum
## gnupg
if [ ! -e "$HOME/.gnupg" ]
then
mkdir $HOME/.gnupg
cp $HOME/.mausoleum/gnupg/gpg.conf $HOME/.gnupg/
cp $HOME/.mausoleum/gnupg/pubring.gpg $HOME/.gnupg/
cp $HOME/.mausoleum/gnupg/secring.gpg $HOME/.gnupg/
fi
## mausoleum links
mkdir -p $HOME/.ssh
for f in $HOME/.mausoleum/ssh/*
do
ln -s $f $HOME/.ssh/
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment