Last active
March 8, 2020 01:52
-
-
Save kral2/dd20fa59e5186c15e92439f539ea471e to your computer and use it in GitHub Desktop.
Generate RSA key for OCI API usage and upload it to specified user.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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