Skip to Main Content
Secure SSH to OCI Bastion Host

About This Workshop

Youtube Video

About This Workshop
Connect to your secure OCI bastion host through SSH for a secure and controlled gateway to access your private instances in your VCN. This LiveLab walks you through generating an SSH key, creating a compartment, creating a VCN with public & private subnets, and two compute instances (one public and one private). After the preparing your resources, you will then securely connect through the Cloud Shell using SSH. You will connect to the instance by using your private instance ssh key and your public instance IP address. You will then create your private key file, change security on the file so other users cannot access and re-connect to private instance using your private key and private IP. This allows you to establish a secure connection using SSH to your private instances while maintaining integrity of your OCI environment.

Workshop Info

1 hour

Lab 1: Set Up

Task 1: Generate SSH Key

  • Open Cloud Shell
  • mkdir .ssh
  • cd .ssh
  • ssh-keygen -b 2048 -t rsa -f <<sshkeyname>>
  • ls
  • cat <<sshkeyname>>.pub
  • copy the public key and private keys and save for later

Task 2: Set up Instances

  • Create a compartment
  • Navigate to Identity & Security and select Compartments
  • Click create compartment
  • Name the Compartment Demo and click create compartment

Task 3: Create a VCN with public and private subnets --Using Wizard

  • Navigate to Networking and select Virtual cloud networks
  • Select Start VCN Wizard
  • Name VCN Demo_VCN
  • Select Demo compartment
  • Leave all other inputs as the default
  • Click next
  • Review and hit the Create button to create the VCN
  • Click the View Virtual Cloud Network button

 

Task 4: Create Public Compute Instance

  • Navigate to Compute and select Instances
  • Select Create instance
  • Name instance BastionHost
  • Ensure it is in Demo compartment
  • Ensure it is in public subnet 
  • Paste public keys and paste the public key we created earlier
  • Press create button to create instance
  • Create instance

Task 5: Create Private Instance

  • Name instance private-1
  • Select private subnet
  • Select paste public keys and paste the public key we created earlier
  • Create instance

Lab 2: Secure Shell Access to Bastion Host using CLI

Task 1: SSH into Instances 

  • Open Cloud Shell
  • cd .ssh
  • ssh -i <private_ssh_key> opc@<BastionHost_public_ip_address>
  • cd .ssh
  • vim private_key
  • Paste private key we saved from earlier
  • :wq!
  • chmod 600 private_key
  • ssh -i private_key opc@<private-1_private_ip_address>
  • exit
  • Familiarity with Oracle Cloud Infrastructure (OCI) is helpful
  • Familiarity with VCN/ Networking is helpful
  • Some understanding of cloud and command line terms are helpful

Other Workshops you might like

Ask Oracle
Helping you on LiveLabs