When you create a DBaaS instance, by default the only port open is 22, the SSH port. Now we must remember, these instances are on the public internet so security is priority. Personally, the only 2 ports I open in my DBaaS instances are 22 and 443 (for APEX access). So if we need SQL*Net access, what do we do? We create a tunnel over SSH for SQL*Net in SQL Developer.
Find your Public IP for a DBaaS Instance
Let's go through creating a connection, but before this we need to gather some information. First, we need the public IP of our DBaaS instance. That address can be found on your Database details page. Log into your Public Cloud Account, open the Database Cloud Service page. On this page we can see all of our created instances.
Click on the instance you want to connect to. This brings up the database details page. Here we can see the SID, the PDB name, resources used as well as the public IP.
Make note of the public IP and PDB1 connect descriptor for our SQL Developer connection.
Get the Key
Now that we have the public IP, we need one more item for our secured connection, the private key. When you created a DBaaS instance, you created a public and private key. The Public Key was used on instance creation. The private key will be used to connect to the instance at the OS level. We need this key for our SQL Developer connection.
We need to add an SSH host. In the toolbar across the top, View, select SSH. A new SSH view should appear.
Now right click SSH Hosts and Add a host:
Fill in the details for your SSH host
Now add a ssh key, start by clicking the Use Key File checkbox
then click the file browse button and add a key
Next continue in the modal and create a New Local Port Forward.
Name your port forward and ensure the port is 1521. When done, click OK.
The SSH view should look like the following:
We need to alter our SQL net connection now. Edit the connection details of your database connection.
Now in the Port Forward section, select your SSH connection.
When finished, save the connection.
Hit the test button to check the connection.
You have now created a SQL Developer connection that uses SSH to tunnel into your DBaaS instance to use SQL*net. Start by changing the connection type to SSH.