Skip to content

Instantly share code, notes, and snippets.

@dustinmm80
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinmm80/5125ce2e7d3ac6148cff to your computer and use it in GitHub Desktop.
Save dustinmm80/5125ce2e7d3ac6148cff to your computer and use it in GitHub Desktop.
Bootstrapping a Conjur identity with host-factory
#!/bin/bash
# Creates a host identity using host-factory and places it in /etc/conjur.identity
# Requires the Conjur CLI and host-factory plugin to be installed
# Usage:
# ./hostfactory_bootstrap.sh 92198eb129peh812ue9puihd891 mynewhost1
hostfactory_token=$1
host_name=$2
conjur hostfactory hosts create ${hostfactory_token} ${host_name} > host.json
conjur_endpoint=$(cat /etc/conjur.conf | sed -n 2p | cut -d ' ' -f 2)"/authn"
# or you could just hardcode ^ if you have one Conjur endpoint
cat << IDENTITY > /etc/conjur.identity
machine ${conjur_endpoint}
login host/$(cat host.json | jsonfield id)
password $(cat host.json | jsonfield api_key)
IDENTITY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment