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,
20 # check for presence of secret key
21 # FIXME: is this the proper test to be doing here?
22 fingerprint_host_key >/dev/null \
23 && failure "An OpenPGP host key already exists."
25 hostName=${1:-$(hostname -f)}
27 userID="ssh://${hostName}"
30 mkdir -p "$GNUPGHOME_HOST"
31 chmod 700 "$GNUPGHOME_HOST"
33 log verbose "importing ssh key..."
34 # translate ssh key to a private key
35 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" | \
38 # find the key fingerprint of the newly converted key
39 HOST_FINGERPRINT=$(fingerprint_host_key)
40 export HOST_FINGERPRINT
42 # export public key to file
43 gpg_host_export_to_ssh_file
45 # show info about new key