X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=src%2Fmonkeysphere;h=46abf6fce659dcc09f7017ac97e2a9c814a85105;hb=e546effef3381d1cec0b1c18cb4b1e27d5c28930;hp=5444cb012156adb91730046e9b1602153a99f549;hpb=47ab7d6bcb9922a984f103a9385f068e0fb3c4bc;p=monkeysphere.git diff --git a/src/monkeysphere b/src/monkeysphere index 5444cb0..46abf6f 100755 --- a/src/monkeysphere +++ b/src/monkeysphere @@ -6,8 +6,9 @@ # Jameson Rollins # Jamie McClelland # Daniel Kahn Gillmor +# Micah Anderson # -# They are Copyright 2008, and are all released under the GPL, version 3 +# They are Copyright 2008-2009, and are all released under the GPL, version 3 # or later. ######################################################################## @@ -41,9 +42,13 @@ Monkeysphere client tool. subcommands: update-known_hosts (k) [HOST]... update known_hosts file update-authorized_keys (a) update authorized_keys file + import-subkey (i) import existing ssh key as gpg subkey + --keyfile (-f) FILE key file to import + --expire (-e) EXPIRE date to expire gen-subkey (g) [KEYID] generate an authentication subkey --length (-l) BITS key length in bits (2048) --expire (-e) EXPIRE date to expire + ssh-proxycommand ssh proxycommand subkey-to-ssh-agent (s) store authentication subkey in ssh-agent version (v) show version number help (h,?) this help @@ -51,6 +56,47 @@ subcommands: EOF } +# 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." +} + # generate a subkey with the 'a' usage flags set gen_subkey(){ local keyLength @@ -59,10 +105,6 @@ gen_subkey(){ local gpgOut local userID - # set default key parameter values - keyLength= - keyExpire= - # get options while true ; do case "$1" in @@ -376,10 +418,18 @@ case $COMMAND in RETURN="$?" ;; + 'import-subkey'|'i') + import_key "$@" + ;; + 'gen-subkey'|'g') gen_subkey "$@" ;; + 'ssh-proxycommand'|'p') + ssh-proxycommand "$@" + ;; + 'subkey-to-ssh-agent'|'s') subkey_to_ssh_agent "$@" ;;