summaryrefslogtreecommitdiff
path: root/src/monkeysphere
diff options
context:
space:
mode:
authorJameson Graef Rollins <jrollins@finestructure.net>2009-01-15 22:32:45 -0500
committerJameson Graef Rollins <jrollins@finestructure.net>2009-01-15 22:32:45 -0500
commitdbb58c04bf0a06071c740495636b55775023979d (patch)
treea2dd0ec926cd7123cc9bfb3736b841b4c7721801 /src/monkeysphere
parentcff95034ab2c2d77352fe08f033028584a6b5dbc (diff)
work on fleshing out the new functionality for the next release,
including new functions: import-key, add-revoker, revoke-key, etc.
Diffstat (limited to 'src/monkeysphere')
-rwxr-xr-xsrc/monkeysphere52
1 files changed, 48 insertions, 4 deletions
diff --git a/src/monkeysphere b/src/monkeysphere
index 5444cb0..463a1b1 100755
--- a/src/monkeysphere
+++ b/src/monkeysphere
@@ -41,6 +41,9 @@ 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
@@ -51,6 +54,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 +103,6 @@ gen_subkey(){
local gpgOut
local userID
- # set default key parameter values
- keyLength=
- keyExpire=
-
# get options
while true ; do
case "$1" in
@@ -376,6 +416,10 @@ case $COMMAND in
RETURN="$?"
;;
+ 'import-subkey'|'i')
+ import_key "$@"
+ ;;
+
'gen-subkey'|'g')
gen_subkey "$@"
;;