I'm going to show you how to connect to your database cloud service instance
running remotely in an Oracle cloud virtual machine or VM
To access the database in your VM you can either have a cloud service administrator open
ports or as we will show here you can use Secure Shell SSH client software to
connect securely to the VM and log into your database. Several SSH clients are
freely available including the SSH utility on Linux platforms and the PuTTY
utility on Windows platforms. In this video we will see how to use PuTTY to
tunnel through an SSH connection to the VM hosting a database cloud service
instance and with that connection established we will see how you can then
use the PuTTY command window and other tools like SQL Developer to do
typical database tasks. First, you generate and store a private and public
key pair on your local PC using the tools such as the puttygen key generator.
Make a note of where you store the keys as you'll need this path when you create
your Database as a Service instance. Next, when you create a Database as a Service
instance you provide the public key which gets stored on the Database as a
Service Cloud Server. Later, when you initiate an SSH connection, data
encryption and decryption using the public and private keys allow your
client and Database as a Service host to authenticate each other without passing
the private key across the network. Before you use the PuTTY program to
connect to a VM, you will need to find the IP address, SQL*Net port, and SID of
your database instance on your VM and you'll need access to the SSH key file
that you used when you created your database instance. To
find the connection information for the database instance on your VM, connect to the
Database Cloud Service console and click the name of the database instance you
want to connect to. Write down the IP address, SQL*Net port, and SID name.
Open the PuTTY utility in your local Windows environment and in the initial dialog
enter the IP address you just noted in the hostname field. For connection type
select SSH. In the connection category select data and then the auto
login username enter Oracle. In the Connection category expand SSH and select Auth. Click
the Browse button to select the key file that you generated and stored on your
local PC.
Click Tunnels and take the local machine SQL*Net port 1521 and forward it to
the SQL*Net port on the remote cloud VM. Click Add. Scroll up and back at
Session, provide a name for the session and click Save.
When you click Open, because this is the first time you are connecting to the VM,
the SSH utility prompts you to confirm the public key. Click Yes. You are in the
PuTTY command window connected to the VM as the user Oracle, and you are in the
Oracle Users home directory. You can now use SQL*Plus to connect to your VM's database
instance. Now that you're in the database you can perform database tasks. For
example, let's simply select tablename from user tables. In the PuTTY command window
on your PC
we see listed the user tables on the database running in your remote VM. Now
that you've tunneled into the VM using PuTTY on your local computer you can
keep the PuTTY session open and use other local tools to connect to the database
using that SSH tunnel. For example, here we see a SQL Developer connection pointing
to
hostname localhost and port 1521 which will use the SSH tunnel to connect to
the remote VM's database. Once SQL Developer connects to your database in
the VM, you can use a worksheet to issue commands such as this same select
tablename from user tables. At the output panel at the bottom of the SQL
Developer window, we see listed the database's user tables. And that's it.
You now know how to connect to the database running in your Oracle Database
Cloud Service VM.
Thank you for watching.