2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
4 # Monkeysphere host import-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,
24 # check that key file specified
25 if [ -z "$sshKeyFile" ] ; then
26 failure "Must specify ssh key file to import, or specify '-' for stdin."
29 # fail if hostname not specified
30 if [ -z "$hostName" ] ; then
31 failure "You must specify a fully-qualified domain name for use in the host certificate user ID."
34 userID="ssh://${hostName}"
37 mkdir -p "${MHDATADIR}"
38 mkdir -p "${GNUPGHOME_HOST}"
39 chmod 700 "${GNUPGHOME_HOST}"
41 # import ssh key to a private key
42 if [ "$sshKeyFile" = '-' ] ; then
43 log verbose "importing ssh key from stdin..."
44 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" \
47 log verbose "importing ssh key from file '$sshKeyFile'..."
48 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" \
53 # load the new host fpr into the fpr variable. this is so we can
54 # create the gpg pub key file. we have to do this from the secret key
55 # ring since we obviously don't have the gpg pub key file yet, since
56 # that's what we're trying to produce (see below).
57 load_fingerprint_secret
59 # export to gpg public key to file
62 log info "host key imported:"
64 # show info about new key