Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate RSA key for OCI API usage and upload it to specified user.
#!/bin/sh
# Last update : March, 2020
# Author: cetin.ardal
# Description: Generate RSA key for OCI API usage and upload it to specified user.
COLOR_TITLE="\033[32m" # green
COLOR_TITLE1="\033[91m" # light red
COLOR_NORMAL="\033[39m"
USER_OCID="<my-user-ocid>"
OCI_API_KEY=my_oci_api_key
if [ ! -f ${OCI_API_KEY}_public.pem ]; then
echo "${COLOR_TITLE}New RSA Key:${COLOR_TITLE1} ${OCI_API_KEY}.pem${COLOR_NORMAL}"
openssl genrsa -out $OCI_API_KEY.pem 2048
chmod go-rwx $OCI_API_KEY.pem
openssl rsa -pubout -in $OCI_API_KEY.pem -out ${OCI_API_KEY}_public.pem
else
echo "${COLOR_TITLE1} ${OCI_API_KEY}_public.pem${COLOR_TITLE} will be used."
fi
echo "${COLOR_TITLE}Adding ${COLOR_TITLE1}${OCI_API_KEY}_public.pem ${COLOR_TITLE}as OCI API signing key for user: ${COLOR_TITLE1}${USER_OCID}${COLOR_NORMAL}"
oci iam user api-key upload --user-id $USER_OCID --key-file ${OCI_API_KEY}_public.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.