AWS Database Blog
Using external Kerberos authentication with Amazon RDS for Oracle
In the first post in this series, Preparing on-premises and AWS environments for external Kerberos authentication for Amazon RDS, we built the infrastructure for a one-way forest trust between an on-premises Microsoft Active Directory (AD) domain (trust: incoming) and an AWS Managed Microsoft AD domain (trust: outgoing) provided by AWS Directory Service. In this post, we demonstrate how to join an Amazon Relational Database Service (Amazon RDS) for Oracle instance to an AWS Managed Microsoft AD and use external Kerberos and Microsoft AD to authenticate database (DB) users.
Prerequisites
Before we start, make sure that you have prepared your on-premises and AWS environments, as shown in the following architectural diagram, including one on-premises AD user joedoe@onprem and one Windows and one Linux client, which are joined to the on-premises AD domain onprem.local.

Creating RDS for Oracle instances and joining them to an AWS Managed Microsoft AD domain
We first create RDS for Oracle instances in the aws-acc-1 and aws-acc-2 accounts and join the instances to the AWS Managed Microsoft AD domain.
- Log in to the Amazon RDS console from
aws-acc-1. - Create the DB subnet group
aws-acc-1-db-subnet-group, which includes the three subnets inaws-acc-1-rds-vpc.

- Create the security group
aws-acc-1-rds-vpc-allow-connectionto allow connection from on-premises clients (inon-prem-client-vpc) to access Amazon RDS for Oracle via TCP on port 1521.

- On the Amazon RDS console, create the RDS for Oracle instance
oracle-acc-1-kerberos-19-0in the DB subnet groupaws-acc-1-db-subnet-group. - For VPC security group, select Choose existing.
- For Existing VPC security groups, enter the security group you created.
- For Database authentication options, select Password and Kerberos authentication.
- Choose Browse Directory.

- In the Choose directory section, select myaws.com.
- Choose Choose.

You can now see ad.myaws.com in the Directory field.

After successfully creating the RDS for Oracle instance, we see that the instance has joined the AWS Managed Microsoft AD, and the directory status shows as kerberos-enabled.

We can also verify the directory status via the AWS Command Line Interface (AWS CLI). See the following code:
You can also create the RDS for Oracle instance via the AWS CLI:
For Amazon RDS for Oracle to call AWS Directory Service for you, you need an AWS Identity and Access Management (IAM) role that uses the managed IAM policy AmazonRDSDirectoryServiceAccess. When you create a DB instance on the AWS Management Console and the console user has the iam:CreateRole permission, the console creates this role automatically. For this use case, the role name is rds-directoryservice-kerberos-access-role.
For instructions on creating the role manually, see Create an IAM Role for Amazon Aurora to Access the AWS Directory Service. When you create this role, choose Directory Service, and attach the AWS managed policy AmazonRDSDirectoryServiceAccess to it.
For existing RDS for Oracle instances, we can modify the instance to join the AWS Managed Microsoft AD from the Amazon RDS console, or the AWS CLI:
- Repeat these steps in
aws-acc-2to create an RDS for Oracle instance and join the instance to the shared AWS Managed Microsoft AD, with following details:
-
- DB instance name –
oracle-acc-2-kerberos-19-0 - DB subnet groups –
aws-acc-2-db-subnet-group - Security group –
aws-acc-2-rds-vpc-allow-connection - Database authentication options – Password and Kerberos authentication
- Directory –
ad.myaws.com(d-97671c1f8c), shared byaws-acc-1
- DB instance name –
- On the Amazon RDS console, make sure the RDS for Oracle instance in
aws-acc-2has joined the shared AWS Managed Microsoft AD successfully.

We can also verify the status via the AWS CLI:
- In
on-prem-account, log in to the Windows client and install SQL Developer and Oracle Client. - Configure
tnsnames.orafor the two RDS for Oracle instances:
- Log in to the RDS for Oracle instance created in
aws-acc-1with the primary user account. - Create an on-premises AD user in the database. The username created in the database must be in uppercase.

- Log in to RDS for Oracle instance created in
aws-acc-2with the primary user account. - Create an on-premises AD user in the database in uppercase.
Logging in to RDS for Oracle instances with SQL*Plus on a Windows client
To use external Kerberos and Microsoft AD to log in to RDS for Oracle instances with SQL*Plus on a Windows client, complete the following steps:
- Log in as AD user
joedoe@onpremto the Windows client that is joined to the on-premises domainonprem.local. - Create a
krb5.conffile (C:\Oracle_Home\krb5.conffor this post) to point to the on-premises domain and AWS Managed Microsoft AD domain:
- Modify the
sqlnet.orafile inORACLE_HOMEas the following:
- Connect to the RDS for Oracle instance created in
aws-acc-1with SQL*Plus; the connection is made successfully without a password.

- Connect to the RDS for Oracle instance created in aws-acc-2 with SQL*Plus (also without a password).

Logging in to RDS for Oracle instances with SQL Developer on a Windows client
To use external Kerberos and Microsoft AD to log in to RDS for Oracle instances with SQL Developer on a Windows client, complete the following steps:
- Log in as AD user
joedoe@onpremto the Windows client that is joined to the on-premises domainonprem.local. - Modify the
sqlnet.orafile inORACLE_HOMEas the following:
As of this writing, SQL Developer supports the connection through Kerberos only when the ticket is manually generated with okinit. Using Windows in-memory TGE (OSMSFT) rather than credential cache is not supported by SQL Developer [Oracle Doc ID 1609359.1]. This is why we need a different sqlnet.ora file with SQL*Plus and SQL Developer.
- Launch SQL Developer.
- Under Tools, choose Preferences.
- In the Preferences section, expand Database.
- Choose Advanced.
- For Config File (krb5.conf), enter the path of the Kerberos
krb5.conffile. - For Credential Cache File, enter the path to the temporary file that holds your client’s Kerberos ticket credential cache.
- Choose OK.

- Open DOS Prompt and generate a Kerberos ticket manually with the command
okinit. - Provide the password for AD user
joedoe@onprem.

A file holding the client’s Kerberos ticket credential cache is created; the location and filename are defined in the krb5.conf file.
- Launch SQL Developer.
- Choose New Connection.
- For Authentication Type, choose Kerberos.
- For Hostname, enter the hostname for the RDS for Oracle instance created in
aws-acc-1. - For Port, enter
1521. - For SID, enter
ORCL.

You can see the connection to the RDS for Oracle instance in aws-acc-1 is made as DB user JOEDOE@ONPREM.LOCAL via Kerberos authentication.

You can also see the connection to the RDS for Oracle instance in aws-acc-2 is made as DB user JOEDOE@ONPREM.LOCAL via Kerberos authentication.

Logging in to RDS for Oracle instances with SQL*Plus on a Linux client
To use external Kerberos and Microsoft AD to log in to RDS for Oracle instances with SQL*Plus on a Linux client, complete the following steps:
- Install Oracle Client on a Linux client, which you created and configured in the post Preparing on-premises and AWS environments for external Kerberos authentication for Amazon RDS.
- Confirm that the
/etc/krb5.confis configured as the following:
- Configure the
tnsnames.orafile under the$ORACLE_HOME/network/admindirectory for the two RDS for Oracle instances as the following:
- Configure the
sqlnet.orafile under the$ORACLE_HOME/network/admindirectory as the following:
- Log in to the Linux client as
joedoe@onprem. - Generate a Kerberos ticket manually with the command
okinit<username>. - Provide the AD password for the user.

- You can make connections to the RDS for Oracle instances created in
aws-acc-1andaws-acc-2without a password via Kerberos authentication.

Summary
In this post, we demonstrated DB user authentication for Amazon RDS for Oracle using external Kerberos and Microsoft AD, based on a one-way forest trust between an on-premises AD domain and an AWS Managed Microsoft AD domain. For instructions on creating this trust environment, see Preparing on-premises and AWS environments for external Kerberos authentication for Amazon RDS.
About the Authors
Zhen Wang is an RDS Cloud Support Engineer at Amazon Web Services.
Sundar Raghavan is a Senior Specialist Solutions Architect at Amazon Web Services.