Stop all creation of a ssh_host_rsa_key.pub. Use openpgp2ssh to get
[monkeysphere.git] / src / share / mh / import_key
1 # -*-shell-script-*-
2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
3
4 # Monkeysphere host import-key subcommand
5 #
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>
10 #
11 # They are Copyright 2008-2009 and are all released under the GPL,
12 # version 3 or later.
13
14 import_key() {
15
16 local hostName
17 local userID
18
19 hostName=${1:-$(hostname -f)}
20 userID="ssh://${hostName}"
21
22 # create host home
23 mkdir -p "${MHDATADIR}"
24 mkdir -p "${MHTMPDIR}"
25 mkdir -p "${GNUPGHOME_HOST}"
26 chmod 700 "${GNUPGHOME_HOST}"
27
28 log verbose "importing ssh key..."
29 # translate ssh key to a private key
30 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" \
31     | gpg_host --import
32
33 # load the new host fpr into the fpr variable.  this is so we can
34 # create the gpg pub key file.  we have to do this from the secret key
35 # ring since we obviously don't have the gpg pub key file yet, since
36 # that's what we're trying to produce (see below).
37 load_fingerprint_secret
38
39 # export to gpg public key to file
40 create_gpg_pub_file
41
42 # show info about new key
43 show_key
44
45 }