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 "${MHDATADIR}"
45 mkdir -p "${MHTMPDIR}"
46 mkdir -p "${GNUPGHOME_HOST}"
47 chmod 700 "${GNUPGHOME_HOST}"
49 log debug "generating host key..."
50 gpg_host --batch --gen-key <<EOF
52 Key-Length: $keyLength
55 Expire-Date: $keyExpire
62 # load the new host fpr into the fpr variable
63 load_fingerprint_secret
65 # export the host secret key to the monkeysphere ssh sec key file
66 # NOTE: assumes that the primary key is the proper key to use
67 log debug "creating ssh secret key file..."
69 gpg_host --export-secret-key "$HOST_FINGERPRINT" | \
70 openpgp2ssh "$HOST_FINGERPRINT" > "${MHDATADIR}/ssh_host_rsa_key")
71 log info "SSH host secret key file: ${MHDATADIR}/ssh_host_rsa_key"
73 # export the host public key to the monkeysphere ssh pub key file
74 log debug "creating ssh public key file..."
75 ssh-keygen -y -f "${MHDATADIR}/ssh_host_rsa_key" > "$HOST_KEY_PUB"
76 log info "SSH host public key file: $HOST_KEY_PUB"
78 # export to gpg public key to file
81 # show info about new key