-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathboundary-vault-ca-hosts.nomad.hcl
61 lines (42 loc) · 1.31 KB
/
boundary-vault-ca-hosts.nomad.hcl
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
job "vault_ssh_ca" {
region = "global"
datacenters = ["eu-west-2a","eu-west-2b","eu-west-2c","eu-west-2"]
type = "batch"
/*
vault {
policies = ["superuser"]
change_mode = "restart"
namespace = "=admin/guystack"
}
*/
task "vault_ssh_ca_install" {
driver = "raw_exec"
template {
data = <<EOH
set -v
export VAULT_ADDR=https://guylabstack-vault-public-vault-a78b392f.1ee20bcf.z1.hashicorp.cloud:8200
export VAULT_NAMESPACE=admin/guylabstack
export VAULT_TOKEN=
# Add the public key to all target host's SSH configuration
vault read -field=public_key ssh-client-signer/config/ca > /etc/ssh/trusted-user-ca-keys.pem
# Setting up /etc/ssh/sshd_config
grep -qxF 'TrustedUserCAKeys /etc/ssh/trusted-user-ca-keys.pem' /etc/ssh/sshd_config || sudo echo 'TrustedUserCAKeys /etc/ssh/trusted-user-ca-keys.pem' >> /etc/ssh/sshd_config
# restarting SSHD
sudo systemctl restart sshd
# remove your authorised_keys, if any.
if [ -f /home/ubuntu/.ssh/authorized_keys ]; then
mv /home/ubuntu/.ssh/authorized_keys /home/ubuntu/.ssh/backup
fi
# Uncomment the line below if you run into issues
# mv /home/ubuntu/.ssh/backup /home/ubuntu/.ssh/authorized_keys
exit 0
EOH
destination = "script.sh"
perms = "755"
}
config {
command = "bash"
args = ["script.sh"]
}
}
}