summaryrefslogtreecommitdiff
path: root/src/subcommands/mh/show-key
blob: c62ec166cd1db2436a1b08ebc8700c4ff4a8602e (plain)
  1. #!/usr/bin/env bash
  2. # Monkeysphere host show-key subcommand
  3. #
  4. # The monkeysphere scripts are written by:
  5. # Jameson Rollins <jrollins@fifthhorseman.net>
  6. # Jamie McClelland <jm@mayfirst.org>
  7. # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
  8. #
  9. # They are Copyright 2008, and are all released under the GPL, version 3
  10. # or later.
  11. local fingerprintPGP
  12. local fingerprintSSH
  13. local ret=0
  14. # FIXME: you shouldn't have to be root to see the host key fingerprint
  15. if is_root ; then
  16. check_host_keyring
  17. fingerprintPGP=$(fingerprint_server_key)
  18. gpg_authentication "--fingerprint --list-key --list-options show-unusable-uids $fingerprintPGP" 2>/dev/null
  19. echo "OpenPGP fingerprint: $fingerprintPGP"
  20. else
  21. log info "You must be root to see host OpenPGP fingerprint."
  22. ret='1'
  23. fi
  24. if [ -f "${SYSDATADIR}/ssh_host_rsa_key.pub" ] ; then
  25. fingerprintSSH=$(ssh-keygen -l -f "${SYSDATADIR}/ssh_host_rsa_key.pub" | \
  26. awk '{ print $1, $2, $4 }')
  27. echo "ssh fingerprint: $fingerprintSSH"
  28. else
  29. log info "SSH host key not found."
  30. ret='1'
  31. fi
  32. return $ret