[OCI] How to create Linux based Compute Instance (Virtual Machine) and SSH to it in OCI?

 

A compute instance in Oracle Cloud Infrastructure (OCI) refers to a virtual machine (VM) that runs within the Oracle Cloud environment. It's essentially a virtualized computing environment that provides computational resources such as CPU, memory, storage, and networking capabilities.

Here are some key points about compute instances in OCI:

  1. Virtual Machines: Compute instances in OCI are virtual machines that run on physical servers within Oracle's data centers. Users can create, manage, and run multiple compute instances to host applications, databases, or perform various computing tasks.

  2. Flexibility: OCI offers a wide range of compute instance shapes, each with different combinations of CPU, memory, and network resources. Users can choose the appropriate instance shape based on their workload requirements, whether it's a small development environment or a high-performance production application.

  3. Operating Systems: OCI supports various operating systems for compute instances, including Oracle Linux, CentOS, Ubuntu, Windows, and others. Users can select the desired operating system image when creating an instance.

  4. Networking: Compute instances in OCI are integrated with Oracle's Virtual Cloud Network (VCN), allowing users to configure networking settings such as subnets, security lists, and routing. This enables users to establish private networks, control access, and securely connect instances to other services within OCI or external networks.

  5. Storage: OCI provides different storage options for compute instances, including block volumes, object storage, and file storage. Users can attach block volumes to instances for additional storage capacity or use object storage for scalable and durable data storage.

  6. Security: OCI offers robust security features to protect compute instances and data. This includes network security through security lists and firewalls, identity and access management (IAM) for controlling user access, encryption for data at rest and in transit, and compliance certifications for regulatory requirements.

  7. Scalability and Management: Users can easily scale compute instances up or down based on changing workload demands. OCI also provides monitoring and management tools to monitor instance performance, automate tasks, and ensure high availability and reliability.

     

Follow the below steps to create a Linux Virtual Machine in OCI:


  • Login to Oracle Cloud Infrastructure (OCI) console and click on the Navigation Menu button
  • Click on Compute link in the Navigation Menu, then click on the Instances
  • Instances page will be displayed with current compartment selected as root compartment. Select the compartment in which you want to place your compute instance. Try to avoid creating resources in root compartment. After selecting the right compartment click on Create instance button
 
In Oracle Cloud Infrastructure (OCI), a compartment is a fundamental logical container used to organize and isolate cloud resources within a tenancy. Compartments help in managing and securing resources by providing a way to group related resources together and control access to those resources.
  • Create Compute Instance page will appear. Provide the Name of the Compute Instance
  • Select any Availability Domain from the available list for the placement of your Compute Instance. Since, our Home Region is US East (Ashburn), so we can see 3 availability domains:  AD 1, AD 2 and AD 3. Number of availability domains depends on selected Region. Some regions have only one availability domain. Click here to view entire list of Regions & Availability Domains
  • On right side, you will be able to see the Estimated Cost for your Compute Instance. Currently, you can see that cost is calculated for Shape and Boot Volume.
  • Scroll down to view the Shape and Image.
  • Shape:

    • The "shape" refers to the compute resources allocated to the VM instance, such as CPU, memory, and network bandwidth. Each shape has predefined specifications that determine the amount of resources available to the instance.
    • Shapes come in various sizes and configurations to meet different performance and cost requirements. For example, you might choose a shape with a higher number of CPUs and more memory for a high-performance workload, while opting for a smaller shape with fewer resources for a development or testing environment.
    • OCI provides a wide range of compute shapes, allowing users to select the most suitable shape based on their application requirements and budget constraints.
  • Image:

    • The "image" refers to the software environment installed on the VM instance. It includes the operating system and any additional software or configurations needed for the instance.
    • OCI offers a variety of pre-configured images for different operating systems, such as Oracle Linux, CentOS, Ubuntu, Windows Server, and others. These images come with the necessary software packages and drivers pre-installed, making it easy to deploy new VM instances with the desired operating system.
    • Additionally, OCI allows users to create custom images by capturing snapshots of existing VM instances. This enables users to create reusable images with specific configurations or software setups, streamlining the deployment process for similar instances in the future.
    • Users can choose the appropriate image based on their application requirements, compatibility with existing software, and security considerations.
     
  • Click on Change Image button to view other images. Select the Type of image (like Oracle Linux) to view all versions of that image type. It will also show the Price of that image
 
  •  Similarly you can select different Shape
  • Select Shape Series as Ampere and select the Shape Name having label as "Always Free-Eligible". These are the shapes which does not incur any charges. You can also adjust number of OCPUs and Amount of memory (GB)
 
  •  So, after selecting the new shape, you would see that Cost Estimation has been updated
  • A virtual network interface card (VNIC) connects your instance to a virtual cloud network (VCN) and endpoints in and outside the VCN. Having a public IP address is required to make this instance accessible from the internet
  • VCN refers to the virtual networking environment that allows the instance to communicate with other resources within the same network or across different networks in a cloud infrastructure.
  • A VCN typically includes subnets, route tables, security lists, and gateways that facilitate communication and control traffic within the cloud environment. It provides a way to logically isolate and segment the network resources, helping to ensure security, scalability, and efficient management of cloud infrastructure.
  • If you want to enable public traffic across your Compute Instance, then select the Public Subnet. Otherwise, if you want that only resources within OCI can communicate to your Compute Instance then select the Private Subnet.
  • Here we will be creating a new VCN and Public Subnet using this same wizard only. So, select the below highlighted options and provide name for your VCN and Public Subnet. Also, you can select the different target compartment for your VCN and Subnet.
  • CIDR (CIDR is the short for Classless Inter-Domain Routing) block denotes the range of IP Addresses. For example, for given CIDR block (10.0.0.0/24) below is the range. Use the website https://www.ipaddressguide.com/cidr to calculate the range for the CIDR block
  • As we want to connect to the instance using a Secure Shell (SSH) connection, we will be assigning public IP Address to the instance and then will generate SSH key pairs. Save both private and public key
  • Private key will be saved with extension .key and public key with .pub
 
 
 
  •  If you want to customize the Boot Volume for this Compute Instance, select the check box and adjust the size. Then click on Create button to create the Compute Instance with selected configurations. 
 
 
 
 
  • After clicking on  Create button, Compute Instance will start provisioning:



  • Once, instance is provisioned you will see the Public IP Address which you can use to login to your compute instance using SSH. Default username will be opc




Connecting to Compute Instance using SSH connection:
  • To connect using putty we need .ppk file. Now open the PuTTygen and make sure that in Keys-> SSH-2 RSA key is selected
  • Select Conversions -> Import Key
  • Load private key dialog box will appear. Select the private key (.key file) and click Open
  • Click on Save private key button to save the .ppk file
  • Select Yes to generate the key without any passphrase
  • Provide any name for this key file and click Save button. This will save the key file like LinuxVM.ppk
  • Open putty and enter the Public IP Address of the Compute Instance


  •  Select the saved .ppk file in Connection -> SSH -> Auth -> Credentials and click Open button to login to the instance


  • Click on Accept to add the host key to the cache


  • Enter the username as opc and hit Enter


  • You will be connected to the Compute Instance


Comments