summaryrefslogtreecommitdiff
path: root/src/share/mh/import_key
blob: 74dc0b3816d7584b2483498238efb6599299896b (plain)
  1. # -*-shell-script-*-
  2. # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
  3. # Monkeysphere host import-key subcommand
  4. #
  5. # The monkeysphere scripts are written by:
  6. # Jameson Rollins <jrollins@finestructure.net>
  7. # Jamie McClelland <jm@mayfirst.org>
  8. # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
  9. #
  10. # They are Copyright 2008-2009 and are all released under the GPL,
  11. # version 3 or later.
  12. import_key() {
  13. local hostName
  14. local userID
  15. hostName=${1:-$(hostname -f)}
  16. userID="ssh://${hostName}"
  17. # create host home
  18. mkdir -p "${MHDATADIR}"
  19. mkdir -p "${MHTMPDIR}"
  20. mkdir -p "${GNUPGHOME_HOST}"
  21. chmod 700 "${GNUPGHOME_HOST}"
  22. log verbose "importing ssh key..."
  23. # translate ssh key to a private key
  24. PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" \
  25. | gpg_host --import
  26. # load the new host fpr into the fpr variable. this is so we can
  27. # create the gpg pub key file. we have to do this from the secret key
  28. # ring since we obviously don't have the gpg pub key file yet, since
  29. # that's what we're trying to produce (see below).
  30. load_fingerprint_secret
  31. # export to gpg public key to file
  32. create_gpg_pub_file
  33. # show info about new key
  34. show_key
  35. }