summaryrefslogtreecommitdiff
path: root/src/share/mh/import_key
blob: 9be8dce5ba9256d5355ecba07e348a3bf4d3ac59 (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 "$GNUPGHOME_HOST"
  19. chmod 700 "$GNUPGHOME_HOST"
  20. log verbose "importing ssh key..."
  21. # translate ssh key to a private key
  22. PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" | \
  23. gpg_host --import
  24. # load the new host fpr into the fpr variable
  25. load_fingerprint_secret
  26. # export to gpg public key to file
  27. create_gpg_pub_file
  28. # show info about new key
  29. show_key
  30. }