summaryrefslogtreecommitdiff
path: root/src/share/mh/import_key
blob: 9415b4d72ec934463f19ed8e77d39d06fdcef0e0 (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 ssh public key file
  27. create_ssh_pub_file
  28. # export to gpg public key to file
  29. create_gpg_pub_file
  30. # show info about new key
  31. show_key
  32. }