have the import_key also create the ssh pub file, since it is needed to show full...
[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
21 userID="ssh://${hostName}"
22
23 # create host home
24 mkdir -p "$GNUPGHOME_HOST"
25 chmod 700 "$GNUPGHOME_HOST"
26
27 log verbose "importing ssh key..."
28 # translate ssh key to a private key
29 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" | \
30     gpg_host --import
31
32 # load the new host fpr into the fpr variable
33 load_fingerprint_secret
34
35 # export to ssh public key file
36 create_ssh_pub_file
37
38 # export to gpg public key to file
39 create_gpg_pub_file
40
41 # show info about new key
42 show_key
43
44 }