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