-
Notifications
You must be signed in to change notification settings - Fork 0
/
device-setup-example.sh
executable file
·73 lines (54 loc) · 2.57 KB
/
device-setup-example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
CMD="hsm-secrets --mock=mock.pickle"
echo "This script is an example of how to set up a new YubiHSM2 cluster with hsm-secrets."
echo "By default, it uses '--mock=mock.pickle' to avoid needing physical devices, but you can remove"
echo "that flag and adapt the script to set up your real devices."
echo ""
echo "Press Enter to continue or Ctrl+C to abort"
read
rm -f mock.pickle
rm -f hsm-logs.sqlite
function phase_msg() {
echo -e "\n ======================== NEXT PHASE: $1 ======================== \n"
}
phase_msg "Reset all devices to factory defaults"
$CMD hsm reset --alldevs
phase_msg "Apply log audit settings to all devices"
$CMD log apply-settings --alldevs
phase_msg "Install wrap key on all devices"
$CMD hsm backup make-key
phase_msg "Create keys on master device"
$CMD hsm objects create-missing --keys-only
phase_msg "Fetch and clear log (to avoid blocking)"
$CMD --auth-default-admin log fetch --clear hsm-logs.sqlite
phase_msg "Create certificates on master device"
$CMD hsm objects create-missing --certs-only
phase_msg "Fetch and clear log again"
$CMD --auth-default-admin log fetch --alldevs --clear hsm-logs.sqlite
phase_msg "Sanity check: verify fetched logs"
$CMD log verify-all hsm-logs.sqlite --alldevs
phase_msg "Create user auth keys on master device"
echo "(Here you would use YubiKey Manager to reset HSM auth slot and then '$CMD user add-yubikey <username>' to add each user)"
# ykman config usb --enable HSMAUTH
# ykman hsmauth reset
# $CMD user add-yubikey user_john.doe
# $CMD user add-yubikey user_alice.smith
phase_msg "Create service accounts on master device"
$CMD user add-service svc_log-audit svc_attestation svc_nac
phase_msg "Create shared super admin key on master device"
$CMD hsm admin sharing-ceremony -n 5 -t 3 -b
phase_msg "Fetch and clear log again"
$CMD --auth-default-admin log fetch --alldevs --clear hsm-logs.sqlite
phase_msg "Export backup from master device"
$CMD hsm backup export
phase_msg "Fetch and clear log again"
$CMD --auth-default-admin log fetch --alldevs --clear hsm-logs.sqlite
phase_msg "Import backup to the other devices"
$CMD --hsmserial 27600136 hsm backup import yubihsm2-device-27600135-wrapped-backup.tar.gz
$CMD --hsmserial 27600137 hsm backup import yubihsm2-device-27600135-wrapped-backup.tar.gz
phase_msg "Fetch and clear log again"
$CMD --auth-default-admin log fetch --alldevs --clear hsm-logs.sqlite
phase_msg "See that all devices are fully configured and in sync"
$CMD --auth-default-admin hsm compare --alldevs
phase_msg "Disable default admin password from all devices"
$CMD hsm admin default-disable --alldevs