Sean Scott is an Oracle ACE with over 25 years experience IN Oracle technologies

Generate Random Passwords for Automated Oracle Installs

Generate Random Passwords for Automated Oracle Installs

Oracle enforces complexity rules for passwords when creating a database:

Error: password should contain at least two numbers
More info:
password length (minimum:9 maximum:30) characters
password should contain ALL of the following:
         a) at least two uppercase letters
         b) at least two lowercase letters
         c) at least two numbers
         d) at least two special characters, valid characters are # _ -

This can be a bit of a pain when automating database builds for migration, perhaps to Oracle Database Appliance or Oracle Cloud. Eventually the password file from source gets restored. The password isn’t really important in this case, leaving two options.

  1. Use a static password for everything

  2. Generate passwords for each database

Producing random strings is easy, but guaranteeing minimums for upper and lowercase, numbers and special characters from a list is a little more complex.

I addressed this by producing a minimum of each type, adding random characters for length, then shuffling the output into a variable my automation uses to set the database password in the CLI:

__m=$({ </dev/urandom tr -dc 'A-Z' | head -c 2; \ # 2 uppercase
        </dev/urandom tr -dc 'a-z' | head -c 2; \ # 2 lowercase
        </dev/urandom tr -dc '0-9' | head -c 2; \ # 2 numbers
        </dev/urandom tr -dc '#_-' | head -c 2; \ # 2 special
        </dev/urandom tr -dc 'A-Za-z0-9#_\-' | head -c 22; } | \ # 22 random, making 30 characters total
        sed -e "s|.\{1\}|&\n|g" | \ # Break everything onto separate lines
        shuf | \ # Shuffle the result
        tr -d '\n') # Remove line breaks

Pass the value to the CLI:

odacli create-database -n $__sid -m "$__m" ...

Viola!

Add Certificates to Wallets Automatically with DevOps

Add Certificates to Wallets Automatically with DevOps

Loading Fixed Width Data into ATP/ADW with DBMS_CLOUD

Loading Fixed Width Data into ATP/ADW with DBMS_CLOUD