diff --git a/README.md b/README.md index 4ff65ba5449a5aca6e64f216453c0e34dbeb0701..d4f3a36890bd35fda497a5c0e034d730fa19b6ef 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,14 @@ Then, add the following command to gnome-autostart. You should know how to auto- /path/to/this/project/unlock_keyrings.sh /path/to/your_secret ``` +Optionally, if you don't want to enter your GPG smartcard pin every time you log in, add it as parameter to the command. If your pin is e.g. 123456: + +``` +/path/to/this/project/unlock_keyrings.sh /path/to/your_secret 123456 +``` + +This obviously weakens the security of the private key, so obviously only do this if you're comfortable with having your pin stored on your disk in plain text. + You're all set! Re-login and have a try! ## FAQ diff --git a/unlock_keyrings.sh b/unlock_keyrings.sh index 5638eec507b93b04bce18fb9f7b01653808af60d..3211973f9cc3ca4baf8188e4ce559acdc427ae49 100755 --- a/unlock_keyrings.sh +++ b/unlock_keyrings.sh @@ -3,8 +3,9 @@ _self_bin_name="$0" secret_file="$1" +smartcard_pin="$2" -[[ "$secret_file" = '' ]] && echo "Usage: $0 <secret_file>" && exit 1 +[[ "$secret_file" = '' ]] && echo "Usage: $0 <secret_file> [<smartcard pin>]" && exit 1 function where_is_him () { SOURCE="$1" @@ -22,8 +23,13 @@ function where_am_i () { [[ "$_my_path" = "" ]] && where_is_him "$_self_bin_name" || where_is_him "$_my_path" } +gpg_options=() +if [[ ! "$smartcard_pin" = '' ]]; then + gpg_options=("--pinentry-mode" "loopback" "--passphrase" "$smartcard_pin") +fi + cd `where_am_i` && -gpg --decrypt "$secret_file" | bin/unlock_keyrings --secret-file - --quiet +gpg "${gpg_options[@]}" --decrypt "$secret_file" | bin/unlock_keyrings --secret-file - --quiet exit $?