Note:

Access and Manage a Linux Compute Instance using Oracle Cloud Infrastructure

image

Introduction

In this tutorial, we will explain how to access the console of a Linux instance to install applications or perform management operations.

image

Connectivity Approaches

Linux compute instances can be accessed using multiple approaches. We have listed the most common approaches.

Objectives

Approach 1: Connect via SSH to the Compute Instance Public IP Address using a SSH Private Key with the macOS Terminal

In this approach, we will connect to a Linux instance using SSH and the public IP address that is provided by OCI to connect directly to the instance using the macOS terminal.

image

Approach 2: Connect via Terminal Console to the Compute Instance using SSH Username and Password with the OCI Cloud Shell Console

This approach can be used as a backdoor when you do not have any network connectivity to your instance and logging in with SSH is not possible.

Prerequisites for approach 2

We need to create the local username and password first and to do this we need to log in with SSH using the private key using one of the other approaches. This is done in Approach 1, 3, 4, 5 and 6.

It is also possible to create a new local username and password at the instance creation process. But we will show this in another tutorial.

Continue with approach 2

Now that we have created the local username and password we can continue with connecting via the terminal console to the compute instance using SSH username and password with the OCI Cloud Shell console.

In this approach, we will connect to a Linux instance using the local console provided by OCI to connect directly to the instance using the OCI Cloud Shell.

image

Approach 3: Connect via SSH to the Compute Instance Public IP Address using a SSH Private Key with the Royal TSX Application

In this approach, we will connect to a Linux instance using SSH and the public IP address that is provided by OCI to connect directly to the instance using the Royal TSX application.

image

Approach 4: Connect via SSH to the Compute Instance Private IP Address using a SSH Private Key with OCI Cloud Shell

In this approach, we will connect to the Linux instance using the OCI Cloud Shell provided by OCI and connect to the instance using the private IP address.

image

In order to connect to the Linux instance using the private IP address, it is important that the Cloud Shell gets access to the same subnet as where the Linux instance is connected to.

We can do this by plugging the Cloud Shell into the same VCN and subnet where the Linux instance also resides. By default the network is set to Public, but we are going to change this by creating a new private network on the fly.

Approach 5: Connect via SSH to the Compute Instance Private IP Address using SSH Username and Password with OCI Cloud Shell

In Approach 4, we have used the private key to log in to the Linux instance. In this approach, we will use the username and password.

image

image

Approach 6: Connect via SSH to the compute instance private IP address using a SSH private key with OCI Bastion host

In this approach, we will connect to the Linux instance using the OCI Bastion service and from there connect to the instance using the private IP address through a tunnel connection.

image

Bastion plugin is not present.

In this approach, we have enabled the Bastion plugin on an already running Linux instance. We can also enable the Bastion plugin when we create an instance from the start.

Select the Advanced options, select the following options and continue with the creation of the instance.

  1. Click Oracle Cloud Agent.
  2. Select Bastion.

image

When we created a new image from the start and we check the status after the Bastion plugin right after the instance has been created and the status is RUNNING*, we may see an error message with Plugin Bastion not present….

image

It can take a minute before the status is actually changed. Because in the background the plugin needs to be downloaded, installed and started and this takes time. Wait for 5 minutes till the status is changed to Running.

image

When the status is not changed and the message stays Plugin Bastion not present…, it may be the case that the Linux instance is not able to reach the internet to download the Bastion plugin. Troubleshoot the internet, NAT and service gateway inside VCN to make sure your instance is able to access the internet.

Approach 7: Use a Stepstone compute instance inside a Virtual Cloud Network

In this approach, we will create a dedicated Linux instance that we can use as some kind of stepstone or dedicated Bastion and from there we will access the other Linux instance. We are using resources that may cost additional money compared to using the OCI Bastion service that is offered for free by Oracle.

We will not go into details of this approach as this is a combination of the approaches that we have explained earlier.

image

Next Steps

In this tutorial, we have all the possible approaches to access and manage a Linux instance inside OCI. We can either access the Linux instance directly from the internet and console, or we can use an intermediate stepstone like OCI Cloud Shell, Bastion or a dedicated instance.

We have also showed, how we can connect to the instance with SSH using the private or public key and with a local username and password.

All the possible connection approaches are shown in the following image.

image

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.