Various Tutorials
  • About
  • Tutorials
    • 1. Instance for deployment
      • Create instance
      • Install and configure OCI CLI
      • OCI CLI small test
      • Install and configure Terraform
      • Terraform - small test
    • 2. OCI Networking &Terraform
      • 2.1 VCN (basics)
        • 2.1.1 Create a virtual network using Start VCN Wizard
        • 2.1.2 VCN & public subnet (step-by-step in Terraform)
        • 2.1.3 VCN & public subnet (new compartment)
        • 2.1.4 VCN, Terraform and Ansible (Nginx example)
        • 2.1.5 VCN & private subnet (step-by-step in Terraform)
      • 2.2
      • 2.3
    • 3. Untitled
    • 4. Untitled
    • 5. ATP and APEX
      • Setup Autonomous Database
        • Deploying ATP using OCI Interface
        • Deploy with OCI CLI
      • Setup APEX on ATP
      • Connect remotely to ATP
      • ATP, APEX and Jupyter
      • Demo
    • 6. MySQL
      • 6.1. The basics - OCI UI (MySQL DB System)
      • 6.2 The basics - OCI CLI (MySQL DB System)
      • 6.3 Access MySQL DB System
      • 6.4 HeatWave and MySQL DB Service
      • 6.5 Python SDK
      • 6.6 MySQL Replication (Compute Instances)
      • 6.7 Monitoring MySQL instances
        • Deploy MySQL instances
        • Monitoring tools
          • 1. Networking setup
          • 2. Prometheus setup
          • 3. MySQL Prometheus Exporter Setup
          • 4. Grafana setup
          • 5. Grafana metric graphs
    • 7. MySQL OCI &Terraform
      • 7.1 Deploy MySQL DB System with Terraform (basic tutorial)
      • 7.2 Deploy MySQL DB System with Terraform and access the system
      • 7.3 Endpoints
      • 7.4 Channels (troubleshooting)
        • Fixed MySQL source - MDS replication
      • 7.5 Channels (code)
Powered by GitBook
On this page
  • 1. Generate SSH keys
  • 2. Create instance (OCI UI)
  • 3. Save the SSH keys of "deploymentmachine"
  1. Tutorials
  2. 1. Instance for deployment

Create instance

Previous1. Instance for deploymentNextInstall and configure OCI CLI

Last updated 4 years ago

Prerequisites:

This example is done on WSL 2, Ubuntu 20.04.

1. Generate SSH keys

On Linux ( or WSL), use "ssh-keygen" tool to generate private and public ssh keys.

Below example, with a possible output when running ssh-keygen :

For a detailed example on Linux system, check

root@isaacEXE:/home/zack/# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:uktc9tDBOICCkZzktc9tDBOICCkZNcc0ttfMRrtaT0 
The key's randomart image is:
+---[RSA 3072]----+
|..oo..o o. .o    |
|oo o.  + ..o.E   |
|* . .   .o..  .  |
|o. . . . .o .    |
|. o o o S  .     |
|   o = . .       |
|  o . = . .      |
|.=.+o+.. o o .   |
|.+Oo.+o.. . o    |
+----[SHA256]-----+
root@isaacEXE:/home/zack/# ls
root@isaacEXE:/home/zack/# ls ~/.ssh/id_rsa*
id_rsa id_rsa.pub

This command has been run as a root user, therefore the keys have been generated under /root/.ssh folder.

Since I am on a WSL, and I want to copy the ssh public key on my Windows Desktop; I will have to copy the public key in a different folder on Ubuntu, and change the ownership to a non-root user of the system:

In this example, I am saving my ~/.ssh/id_rsa.pub under /home/ocee/ folder

root@isaacEXE:/home/zack/# cp ~/.ssh/id_rsa.pub /home/ocee/
root@isaacEXE:/home/zack/# cd /home/ocee
root@isaacEXE:/home/zack/# # in my case 'zack' is the non-root user
root@isaacEXE:/home/ocee/# chown zack:zack id_rsa.pub 

Now, open a PowerShell with administrator rights, and access WSL files to copy the id_rsa.pub file to Windows Desktop:

Ubuntu files and folders can be access at path:"\\wsl$\Ubuntu"

2. Create instance (OCI UI)

2.1 Go to Oracle Cloud, "Expand" the Quick Actions, and select "Create a VM Instance":

2. Provide a name to your "Always Free Eligible" instance.

You can choose the compartment (here the root compartment). At section "Configure placement and hardware", you are able to change the OS image by clicking "Edit":

You can also change the Availability Domain and choose a fault domain at this step.

As you can well notice, I have chosen an Ubuntu 20.04 image. Notice that all images are in "Always Free Eligible"

3. Add SSH Keys

Go to "Choose public key files" and upload the id_rsa.pub file (we discussed about it at previous point, "Generate SSH Keys")

4. Create the instance

If you like, you can change the boot volume size, however, the "Always Free Eligible" instances are deployed with 46.6 GB (pretty decent, if you plan to use an instance for deploying only)

Once you have done all the above steps, your instance will be in "Provisioning" stage.

As soon as the provisioning is done, your instance will be available and running:

At this stage, you will be provided a Public IP Address and an Username "ubuntu"

Now you can login to this instance from a terminal, via ssh:

Let's test it from PowerShell, under WSL(from obvious reasons, the Public IP has been hidden):

The instance "deploymentmachine" is now responsive and can be accessed.

3. Save the SSH keys of "deploymentmachine"

As we have already seen, if you want to create an instance in the Cloud UI, you will have to provide the public ssh keys of machine from which you want to perform the actions (or in our case, logging in from "deploymentmachine" to the newly created instance via ssh)

If you do things programmatically, you can get away with it (since you just provide the path of your ssh keys as a variable). But, if you want to do it from the Cloud UI, you will have to provide the "deploymentmachine" public ssh keys.

a) Save you public ssh keys under a non-root folder (/home in my case), and change ownage to an non-root user:

root@deploymentmachine:/home# cp /root/.ssh/id_rsa.pub .
root@deploymentmachine:/home# mv id_rsa.pub id_rsa_deployment.pub
root@deploymentmachine:/home# chown ubuntu:ubuntu id_rsa_deployment.pub

b) Save it on your local machine with scp command (in my case, Ubuntu on WSL)

root@ZACK:/home# scp ubuntu@deploymentmachine:/home/id_rsa.pub /home/
id_rsa_deployment.pub                                                                           100%  576    14.2KB/s   00:00
root@ZACK:/home#

c) ... and once again, let's put it on the Desktop:

And now you can create new instances to which you can login via ssh from the "deploymentmachine", just by adding in the Cloud UI the public ssh keys.

an Oracle Cloud account
SSH keys