I finally received my Oracle Database Cloud free trial service, so it’s time to have some fun with it … The first thing you should try is to start the database and try to connect to it, there are in principle two ways to do it. When you receive an instance of Oracle Database Cloud a public IP is assigned to it. With the public IP you could try to connect directly to the database via port 1521, but this will not work as there are some Access Rules which by default look like:

Access to 1521 is disabled by default, you can enable it to provide direct access to your database, but this is not the most secure way to do it.

There is a second approach, so leave the rule related to 1521 port disabled, then with the SSH key you used when you created the Oracle Database Cloud instance, create a tunnel to access the Oracle Database.

The steps required to create the connection via the tunnel are easy to follow, but here there are two approaches as well, probably more but I will stick with these two.

If you created the SSH key using the command:

ssh-keygen -t rsa

Then you can use this in the SSH view from SQL Developer, to create a tunnel to the Oracle Database Cloud instance:

With this you also have a port forwarding screen:

Then when creating the DB connection you have to select the Connection type: SSH

Next, select the Port Forward you defined previously and fill in all relevant information. With this approach you will not be able to allow another tool/app to connect to the Oracle Database Cloud instance, only SQL Developer has access to this tunneling.

The second approach will allow you to create a tunnel that can be used by any local tool/application to connect to the Oracle Database Cloud instance. This approach involves using putty and creating a tunnel to the Oracle Database Instance. There is a big BUT with this approach, so if you generated the SSH keys with “ssh-keygen”, or you downloaded from Oracle after you created the instance, then you cannot use these SSH keys  to create a tunnel with putty.

So here are the steps required to create the SSH keys: use the puttygen.exe tool that comes with putty, click on Generate then move the mouse over the gray area in the middle:

Save the private and the public keys on your PC, then go to Oracle Database Cloud instance and add the new SSH public key:

Select SSH Access, then select the option Key value and press the button Add New Key:

Now is time to configure putty, so open putty and do the following configurations:

Under SSH-> Auth provide the “Private key file for authentication”

Under SSH -> Tunnels edit the “Source port” to indicate 1521 and the “De stination” to be <your_public_ip_for_oracle_cloud_instance>:1521, then press on Add, you should see a screen similar to:

Under Connection->Data set the “Auto-login username” to be “oracle”:

Under Session provide the Host Name to indicate the public IP of the Oracle cloud instance:

Best practice is to save the configuration so that you don’t have to do it again later, now click on Open and you should have a connection opened with Putty to Oracle Database Cloud.

Now simply using the following information, you should be able to connect to database from any local tool/application: