Skip to content

Instantly share code, notes, and snippets.

@BlitzkriegSoftware
Created April 23, 2024 19:46
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 BlitzkriegSoftware/ae0ad12e5c77c5f8bebbd9d265449a89 to your computer and use it in GitHub Desktop.
Save BlitzkriegSoftware/ae0ad12e5c77c5f8bebbd9d265449a89 to your computer and use it in GitHub Desktop.
BASH Script to use SSL to make a K8s USER Certificate
#!/bin/bash
if [ -z "$1" ]; then
echo "$0 username"
exit 1
fi
KEY='./user.key'
CERT='./user.csr'
B64='./user.base64'
# The extra / is for bash on Windows, remove it on Linux
SUBJ="//CN=$1"
openssl genrsa -out $KEY 2048
openssl req -new -key $KEY -out $CERT -subj $SUBJ
cat $CERT | base64 | tr -d "\n" > $B64
echo "Subject: ${SUBJ:1} <-- Don't forget what this was (case sensitive)"
echo "SSL Private: ${CERT} <-- Do not lose this key"
echo "CERT: ${CERT} <-- this is based on your key, but will be different each time generated"
echo "base64: ${B64} <-- Give to K8s Admin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment