Here I have an Oracle database in a private subnet.
1For quickly accessing my database I am using bastion service and port forwarding sessions. This way I don't need to worry about the bastion host security as it is taken care of by Oracle. First I create the bastion. As I will be joining from public internet I don't put any IP/CIDR restrictions.
It can also be created with the following oci cli command
2Then for accessing database on port 1521, I am creating a port forwarding session
Here is the command for port forwarding session with oci cli
I can create managed SSH session for root access. Or creating a port forwarding session on 22 and ssh'ing into localhost can also do the same thing.
3Once the session is created I copy the command, now I need to provide my ssh key and local port 10521 this time
4Now the tunnel is up, and I can connect to database using service name that I find on console. It can be CDB or PDB.
5For SQL*PLus connection string can be formed with many different connect identifiers, here I use the simplest.