diff options
author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2008-06-17 13:34:32 -0400 |
---|---|---|
committer | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2008-06-17 13:34:32 -0400 |
commit | 92c70306aa5f96c8dfa69f2c90dca58908e719f7 (patch) | |
tree | 4f7d220ec09f4364509d909844b56c61222c1596 /src/monkeysphere-server | |
parent | 9715df03ccc1620db97d3fea50e5031f6ed36fde (diff) | |
parent | deb41134ca527508253244cfa8860a2031034825 (diff) |
Merge commit 'jrollins/master'
Diffstat (limited to 'src/monkeysphere-server')
-rwxr-xr-x | src/monkeysphere-server | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/monkeysphere-server b/src/monkeysphere-server index 3cc7454..6279c45 100755 --- a/src/monkeysphere-server +++ b/src/monkeysphere-server @@ -32,7 +32,7 @@ MonkeySphere server admin tool. subcommands: update-users (s) [USER]... update users authorized_keys files - gen-key (g) generate gpg key for the server + gen-key (g) [HOSTNAME] generate gpg key for the server publish-key (p) publish server key to keyserver trust-keys (t) KEYID... mark keyids as trusted update-user-userids (u) USER UID... add/update user IDs for a user @@ -44,14 +44,26 @@ EOF # generate server gpg key gen_key() { + local hostName + + hostName=${1:-$(hostname --fqdn)} + # set key defaults KEY_TYPE=${KEY_TYPE:-"RSA"} KEY_LENGTH=${KEY_LENGTH:-"2048"} KEY_USAGE=${KEY_USAGE:-"auth,encrypt"} - SERVICE=${SERVICE:-"ssh"} - HOSTNAME_FQDN=${HOSTNAME_FQDN:-$(hostname -f)} + 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 + read -p "Key is valid for? ($EXPIRE) " EXPIRE; EXPIRE=${EXPIRE:-"0"} - USERID=${USERID:-"$SERVICE"://"$HOSTNAME_FQDN"} + SERVICE=${SERVICE:-"ssh"} + USERID=${USERID:-"$SERVICE"://"$hostName"} # set key parameters keyParameters=$(cat <<EOF @@ -59,6 +71,7 @@ Key-Type: $KEY_TYPE Key-Length: $KEY_LENGTH Key-Usage: $KEY_USAGE Name-Real: $USERID +Expire-Date: $EXPIRE EOF ) @@ -91,8 +104,9 @@ EOF EOF ) - log "generating server key..." + log -n "generating server key... " echo "$keyParameters" | gpg --batch --gen-key + echo "done." } ######################################################################## @@ -111,10 +125,10 @@ MS_CONF=${MS_CONF:-"$MS_HOME"/monkeysphere-server.conf} [ -e "$MS_CONF" ] && . "$MS_CONF" # set empty config variable with defaults -GNUPGHOME=${GNUPGHOME:-"$MS_HOME"/gnupg} -KEYSERVER=${KEYSERVER:-subkeys.pgp.net} +GNUPGHOME=${GNUPGHOME:-"${MS_HOME}/gnupg"} +KEYSERVER=${KEYSERVER:-"subkeys.pgp.net"} REQUIRED_USER_KEY_CAPABILITY=${REQUIRED_USER_KEY_CAPABILITY:-"a"} -USER_CONTROLLED_AUTHORIZED_KEYS=${USER_CONTROLLED_AUTHORIZED_KEYS:-%h/.ssh/authorized_keys} +USER_CONTROLLED_AUTHORIZED_KEYS=${USER_CONTROLLED_AUTHORIZED_KEYS:-"%h/.ssh/authorized_keys"} export GNUPGHOME @@ -162,7 +176,7 @@ case $COMMAND in ;; 'gen-key'|'g') - gen_key + gen_key "$1" ;; 'publish-key'|'p') |