Compute Service

Table of Contents

Overview

Pre-Requisites

Practice 1: Generate SSH Keys

Practice 2: Creating a Web Server on a Compute Instance

Note: Some of the UIs might look a little different than the screen shots included in the instructions, but you can still use the instructions to complete the hands-on labs.

Overview

Oracle Cloud Infrastructure Compute lets you provision and manage compute hosts, known as instances. You can launch instances as needed to meet your compute and application requirements. After you launch an instance, you can access it securely from your computer, restart it, attach and detach volumes, and terminate it when you’re done with it. Any changes made to the instance’s local drives are lost when you terminate it. Any saved changes to volumes attached to the instance are retained.

Be sure to review Best Practices for Your Compute Instance for important information about working with your Oracle Cloud Infrastructure Compute instance.

Pre-Requisites

Practice 1: Generate SSH Keys

Generate SSH keys to be used later while launching an instance.

MAC/LINUX

  1. Generate ssh-keys for your machine if you don’t have one. As long as an id_rsa and id_rsa.pub key pair is present they can be reused. By default these are stored in ~/.ssh folder. Enter the following command if you are using MAC or Linux Desktop:
   # ssh-keygen
  1. Make sure permissions are restricted, sometimes ssh will fail if private keys have permissive permissions.
    # chmod 0700 ~/.ssh  
    # chmod 0600 ~/.ssh/id_rsa  
    # chmod 0644 ~/.ssh/id_rsa.pub

FOR WINDOWS

  1. Install git for windows. Download Gitbash and install.

  2. Open Git-bash:

  1. Generate ssh-keys by running this command in Gitbash and hit enter for all steps:
# ssh-keygen  
Generating public/private rsa key pair.  
Enter file in which to save the key
(/c/Users/username/.ssh/id\_rsa):  
Created directory '/c/Users/username/.ssh'.  
Enter passphrase (empty for no passphrase): 
Enter same passphrase again:  
Your identification has been saved in /c/Users/username/.ssh/id\_rsa.  
Your public key has been saved in /c/Users/username/.ssh/id\_rsa.pub.  

Note: In Gitbash, C:\Users\username\ is shown as /c/Users/username/

Practice 2: Creating a Web Server on a Compute Instance

Oracle Cloud Infrastructure offers both Bare Metal and Virtual Machine instances:

An Oracle Cloud Infrastructure VM compute instance runs on the same hardware as a Bare Metal instance, leveraging the same cloud-optimized hardware, firmware, software stack, and networking infrastructure.

  1. Navigate to the Compute tab and click Create Instance. We will launch a VM instance for this lab.

  2. The launch browser will automatically fill in the details for launching a single Oracle Linux. Please check each field for better understanding.

Launching an instance is simple and intuitive with few options to select. Provisioning of the compute instance will complete in less than a minute and the instance state will change from provisioning to running.

  1. Once the instance state changes to Running, you can SSH to the Public IP address of the instance.

  1. To connect to the instance, you can use Terminal if you are using MAC or Gitbash if you are using Windows. On your terminal or gitbash enter the following command:

Note: For Oracle Linux VMs, the default username is opc

# ssh opc@<public_ip_address>

If you have a different path for your SSH key enter the following:

# ssh -i <path_to_private_ssh_key> opc@<public_ip_address>
  1. For this lab, we are going to install an Apache HTTP Webserver and try to connect to it over the public Internet. SSH into the Linux instance and run following commands:

Note Apache HTTP Server is an open-source web server developed by the Apache Software Foundation. The Apache server hosts web content, and responds to requests for this content from web browsers such as Chrome or Firefox.

NOTE: Your browser will not return anything because port 80 was not opened into the Security Lists

  1. Click on Virtual Cloud Network and then the VCN you created for this practice. Now click on Security Lists on the left navigation bar for the VCN.

  2. Click on the Default Security List. Here you need to open port 80. Click on Edit All Rules.

  3. Click on + Another Ingress Rule and add the following values as shown below:

  1. Navigate to http://<public_ip_address> (the IP address of the Linux VM) in your browser. And now you should see the index page of the webserver we created above.

Troubleshooting:

If you are unable to see the webserver on your browser, possible scenarios include: