There are lots of wrong and right articles in internet, when you try to execute Hands-on Labs by yourself, there is chance that you could get drifted away or get severely confused, We strictly adhere to Official Oracle Cloud Documentation, offering you reliable and precise information without personal interpretations. This means you can trust our content 100% Genuine.
Prerequisites
Before you create a VCN and Subnets, ensure you have the following:
- An active OCI account.
- Necessary IAM policies to create and manage networking components.
- A clear plan of your network topology and CIDR blocks to avoid overlapping IP addresses.
Lab Task:
Create a Linux public instance using keypair generated with ssh-keygen commands in (OCI) Cloudshell-CLI.
Lab Task Explanation:
Before we begin the Lab we need to create the SSH keypair using Commands in OCI CloudShell CLI.
At the time of Instance creation, you will be presented with option to upload or paste the public key, use nay of this option to create a New Instance.
Lab Task Flow:
- Open OCI Cloud Shell from the OCI Console.
- on the right top corner of the OCI webpage you can find the option for opening (OCI) Cloudshell-CLI, click open it
- Generate a new keypair using the following command:
- The keygeneration process will look like this
- When prompted, enter a file name for the keypair and a passphrase(optional), press enter in your keyboard to generate the keypairs.
- within the (OCI) Cloudshell-CLI, get into the folder where both public and private keys are, and using Linux "cat" command open the public key file (.pub) and copy its code.
- Subnet A is Public subnet.
- Subnet A should have CIDR ip of 10.0.1.0/29.
- Instance should have a private ip of 10.0.1.5.
- Instance should be a Linux machine.
- Sign in to the OCI console.
- Open the navigation menu and click Compute > Instances.
- Click Create Instance.
- In the Create Compute Instance dialog box, provide the necessary information for your instance.
- In the Add SSH Keys section, select Paste SSH keys and paste the public key code which we copied previously.
- Click Create to create your instance.
- Invalid SSH Keys: Make sure your SSH keys are in the correct format.
- Permission Errors: Ensure you have the necessary permissions to create instances and generate keypairs.
- You provide the public key when you create an instance.
- And you keep the private key on a safe place.
- When you connect to the instance using SSH, you provide the path to the private key in the SSH command.
- The public key will be compared with private key for authentication.
- Thus by using both keys you can create and get connected to your instance and do your administrative tasks.
- The Secure Shell (SSH) protocol is a method for securely sending commands to a computer or a server over an unsecured network.
- The SSH network protocol encrypts all traffic between the client and the server while it is in transit.
- SSH utilizes public key cryptography, which involves the use of public and private keys to authenticate and establish a secure connection.
- Thus anyone who requires managing a computer remotely namely, System and network administrators use this protocol to manage remote servers and machines, they can connect to a server and run commands as if they were sitting at the machine.
- Download keypair from pre-given OCI Web Console.
- Generated keypair with ssh-keygen commands.
- using OCI "cloudshell" terminal.
- using windows "powershell".
- using windows "cmd" command prompt
- using "Gitbash" (old windows ver)
- using Open SSH tools (wsl2)
- Generated keypair using GUI - PuTTY Key generator.
- The Cloud Shell machine is a small virtual machine running a Bash shell which you access through the OCI Console. An ephemeral machine to use as a host for a Linux shell, pre-configured with the latest version of the OCI Command Line Interface (CLI) and a number of useful tools and utilites.
- Cloud Shell comes with 5GB of encrypted persistent storage for the home directory, so you can make local changes to your home directory, and then continue working on your project when you come back to Cloud Shell.
- Cloud Shell is free to use (within your tenancy's monthly limits) and doesn't require any setup or prerequisites other than an IAM policy granting access to Cloud Shell. Your Cloud Shell includes a VM provisioned for you that executes in its own tenancy (so it doesn't use any of your tenancy's resources) and hosts your shell in an Oracle Linux OS while you're actively using Cloud Shell.
Task 1: Prepare a clear sample Architectural Diagram
Our OCI Architectural diagram for this Lab is

Note : If you want to create such Cloud Architectural diagrams check this link Click here :
Task 2: Create VCN and public subnet with CIDR in refer to the above sample Architectural Diagram
To proceed with this Lab, we need to have a VCN and Subnets first, we assume that you already have an compartment, else kindly create Architecture by following below Guided Hand-on Lab Link and finish this Task of Creating a VCN or Subnet.
Task 3: Keypair Generation Using OCI Cloud Shell CLI Option
Note : In case of any doubt - Jump to the Detailed vedio explantion given below

ssh-keygen -t rsa -b 2048


Task 4: Create Linux Public instance with the keygeneration together
Step 1: Identify Sample Input
Step 2: Create a Linux Instance Using OCI Generated Keys downloaded from OCI Web Console
When creating your instance and generating your keypair, remember to keep your private key secure. It’s also important to choose a strong passphrase (optional) for your keypair to ensure the security of your instance.

Some common errors you might encounter include
Detailed Video Explanation:
Required concept knowledge
Types of Keys?

There are two types of Keys in a Key pair - public key and private key
Use of SSH Keypair?
What is "SSH" in SSH keypair means?
Difference in Creating Linux Instance and Windows Instance

when is the Key pair generated
Linux / Unix instance | Windows instance |
---|---|
Linux instances use an SSH keypair instead of a password to authenticate a remote user. | Windows instances use username & password to authenticate a remote user. |
|
Usernames & passwords are provided by OCI at the time of instance creation. |
What is (OCI) Cloudshell CLI ?
Oracle Cloud Infrastructure (OCI) Cloud Shell is a web browser-based terminal accessible from the Oracle
Cloud Console.
Cloud Shell is free to use (within monthly tenancy limits), and provides access to a Linux shell, with a
pre-authenticated Oracle Cloud Infrastructure CLI, a pre-authenticated Ansible installation, and other
useful tools for following Oracle Cloud Infrastructure service tutorials and labs. Cloud Shell is a
feature available to all OCI users, accessible from the Console. Your Cloud Shell will appear in the
Oracle Cloud Console as a persistent frame of the Console, and will stay active as you navigate to
different pages of the Console.
Cloud Shell provides:
Reference
Stay tuned for more posts on managing your OCI resources effectively! Happy cloud computing!