diff options
author | Matt Goins <mjgoins@openflows.com> | 2009-01-31 23:34:20 -0500 |
---|---|---|
committer | Matt Goins <mjgoins@openflows.com> | 2009-01-31 23:34:20 -0500 |
commit | b5cdb9cff70a5ab6982e79c7acd0c9bc0a010c49 (patch) | |
tree | 6f74f8c0dcd30775d661d23f62113f14af8031fb /src/share/m/import_subkey | |
parent | c9f3967acec191bd2ec17bfe60359809bf214d0e (diff) | |
parent | 2e534772b9b105ceabfe140d1552770b5c9d76ea (diff) |
Merge commit 'jrollins/master'
Diffstat (limited to 'src/share/m/import_subkey')
-rw-r--r-- | src/share/m/import_subkey | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/share/m/import_subkey b/src/share/m/import_subkey new file mode 100644 index 0000000..aa89958 --- /dev/null +++ b/src/share/m/import_subkey @@ -0,0 +1,54 @@ +# -*-shell-script-*- +# This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) + +# Monkeysphere import-subkey subcommand +# +# The monkeysphere scripts are written by: +# Jameson Rollins <jrollins@finestructure.net> +# Jamie McClelland <jm@mayfirst.org> +# Daniel Kahn Gillmor <dkg@fifthhorseman.net> +# +# They are Copyright 2008-2009, and are all released under the GPL, +# version 3 or later. + +# import an existing ssh key as a gpg subkey + +import_subkey() { + local keyFile="~/.ssh/id_rsa" + local keyExpire + local keyID + local gpgOut + local userID + + # get options + while true ; do + case "$1" in + -f|--keyfile) + keyFile="$2" + shift 2 + ;; + -e|--expire) + keyExpire="$2" + shift 2 + ;; + *) + if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then + failure "Unknown option '$1'. +Type '$PGRM help' for usage." + fi + break + ;; + esac + done + + log verbose "importing ssh key..." + fifoDir=$(mktemp -d ${TMPDIR:-/tmp}/tmp.XXXXXXXXXX) + (umask 077 && mkfifo "$fifoDir/pass") + ssh2openpgp | gpg --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --import & + + passphrase_prompt "Please enter your passphrase for $keyID: " "$fifoDir/pass" + + rm -rf "$fifoDir" + wait + log verbose "done." +} |