2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
4 # Monkeysphere host gen-key subcommand
6 # The monkeysphere scripts are written by:
7 # Jameson Rollins <jrollins@finestructure.net>
8 # Jamie McClelland <jm@mayfirst.org>
9 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
11 # They are Copyright 2008-2009, and are all released under the GPL,
18 local keyLength="2048"
31 if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then
32 failure "Unknown option '$1'.
33 Type '$PGRM help' for usage."
40 hostName=${1:-$(hostname -f)}
41 userID="ssh://${hostName}"
44 mkdir -p "$GNUPGHOME_HOST"
45 chmod 700 "$GNUPGHOME_HOST"
47 log debug "generating host key..."
48 gpg_host --batch --gen-key <<EOF
50 Key-Length: $keyLength
53 Expire-Date: $keyExpire
60 # load the new host fpr into the fpr variable
61 load_fingerprint_secret
63 # export the host secret key to the monkeysphere ssh sec key file
64 # NOTE: assumes that the primary key is the proper key to use
65 log debug "creating ssh secret key file..."
67 gpg_host --export-secret-key "$HOST_FINGERPRINT" | \
68 openpgp2ssh "$HOST_FINGERPRINT" > "${MHDATADIR}/ssh_host_rsa_key")
69 log info "SSH host secret key file: ${MHDATADIR}/ssh_host_rsa_key"
71 # export the host public key to the monkeysphere ssh pub key file
72 log debug "creating ssh public key file..."
73 ssh-keygen -y -f "${MHDATADIR}/ssh_host_rsa_key" > "$HOST_KEY_PUB"
74 log info "SSH host public key file: $HOST_KEY_PUB"
76 # export to gpg public key to file
79 # show info about new key