authorized_keys file (usually ~/.ssh/authorized_keys). `a' may be
used in place of `update-authorized_keys'.
.TP
-.B gen-ae-subkey KEYID
-Generate an `ae` capable subkey. For the primary key with the
-specified key ID, generate a subkey with "authentication" and
-"encryption" capability that can be used for MonkeySphere
-transactions. `g' may be used in place of `gen-ae-subkey'.
+.B gen-subkey KEYID
+Generate an `a` capable subkey. For the primary key with the
+specified key ID, generate a subkey with "authentication" capability
+that can be used for MonkeySphere transactions. `g' may be used in
+place of `gen-subkey'.
.TP
.B help
Output a brief usage summary. `h' or `?' may be used in place of
GPG keys are considered acceptable if the following criteria are met:
.TP
.B capability
-The key must have both the "authentication" and "encrypt" capability
-flags.
+For host keys, the key must have both the "authentication" ("a") and
+"encrypt" ("e") capability flags. For user keys, the key must have
+the "authentication" ("a") capability flag.
.TP
.B validity
The key must be "fully" valid, and must not be expired or revoked.
-#!/bin/sh
+#!/bin/bash
# monkeysphere: MonkeySphere client tool
#
update-userids (u) [USERID]... add/update user IDs
remove-userids (r) [USERID]... remove user IDs
update-authorized_keys (a) update authorized_keys file
- gen-ae-subkey (g) KEYID generate an 'ae' capable subkey
+ gen-subkey (g) KEYID generate an 'a' capable subkey
help (h,?) this help
EOF
}
-# generate a subkey with the 'a' and 'e' usage flags set
-gen_ae_subkey(){
+# generate a subkey with the 'a' usage flags set
+# FIXME: not working yet.
+gen_subkey(){
local keyID
local gpgOut
local userID
keyID="$1"
- # set subkey defaults
- SUBKEY_TYPE=${KEY_TYPE:-"RSA"}
- SUBKEY_LENGTH=${KEY_LENGTH:-"1024"}
- SUBKEY_USAGE=${KEY_USAGE:-"encrypt,auth"}
-
gpgOut=$(gpg --fixed-list-mode --list-keys --with-colons \
"$keyID" 2> /dev/null)
return 1
fi
- userID=$(echo "$gpgOut" | grep "^uid:" | cut -d: -f10)
-
- # set key parameters
- keyParameters=$(cat <<EOF
-Subkey-Type: $SUBKEY_TYPE
-Subkey-Length: $SUBKEY_LENGTH
-Subkey-Usage: $SUBKEY_USAGE
-Name-Real: $userID
+ # set subkey defaults
+ SUBKEY_TYPE=${SUBKEY_TYPE:-"RSA"}
+ #SUBKEY_LENGTH=${SUBKEY_LENGTH:-"2048"}
+ SUBKEY_USAGE=${SUBKEY_USAGE:-"auth"}
+ SUBKEY_EXPIRE=${SUBKEY_EXPIRE:-"0"}
+ cat <<EOF
+Please specify how long the key should be valid.
+ 0 = key does not expire
+ <n> = key expires in n days
+ <n>w = key expires in n weeks
+ <n>m = key expires in n months
+ <n>y = key expires in n years
EOF
-)
-
- echo "The following key parameters will be used:"
- echo "$keyParameters"
-
- read -p "generate key? [Y|n]: " OK; OK=${OK:=Y}
- if [ ${OK/y/Y} != 'Y' ] ; then
- failure "aborting."
- fi
-
- # add commit command
- keyParameters="${keyParameters}"$(cat <<EOF
-
-%commit
-%echo done
+ read -p "Key is valid for? ($SUBKEY_EXPIRE) " SUBKEY_EXPIRE; SUBKEY_EXPIRE=${SUBKEY_EXPIRE:-"0"}
+
+ # generate the list of commands that will be passed to edit-key
+ editCommands=$(cat <<EOF
+addkey
+7
+S
+E
+A
+Q
+$SUBKEY_LENGTH
+$SUBKEY_EXPIRE
+save
EOF
)
echo "generating subkey..."
- echo "$keyParameters" | gpg --batch --gen-key
+ echo "$editCommands" | gpg --expert --command-fd 0 --edit-key "$keyID"
}
########################################################################
update_authorized_keys "$msAuthorizedKeys" "$userAuthorizedKeys" "$userKeysCacheDir"
;;
- 'gen-ae-subkey'|'g')
+ 'gen-subkey'|'g')
keyID="$1"
if [ -z "$keyID" ] ; then
failure "you must specify keyid of primary key."
fi
- gen_ae_subkey "$keyID"
+ gen_subkey "$keyID"
;;
'help'|'h'|'?')