Oracle Developers
Published in

Oracle Developers

Create an OCI Compute instance

By Chris Bensen

If you prefer you can read this blog post on GitHub here.

An Oracle Compute instance is a VM in the cloud you can use as a remote computer to do any task you can imagine; host a personal drop box, share files securily with friends, run a Minecraft server, store weather data in a database, remote control a car over the internet the possibilities are endless:

1. First create a Free Tier Account, then come back here and continue these steps.

2. Click the Cloud Shell icon in the upper right corner. This will open a preconfigured VM that you will use to access your instance. Cloud Shell has the OCI command line tools already configured. You can install these tools locally but this is an easy way to do it.

3. Generate a new RSA key pair.

ssh-keygen -t rsa -N ""-b 2048 -C "cloud_shell" -f ~/.ssh/oci_id_rsa

4. Display the public key and copy it.

cat ~/.ssh/oci_id_rsa.pub

5. You can now minimize the Cloud Shell window and scroll down a little. Click “Create a VM instance” in the Compute box. We will setup the instance to be accessed from the Cloud Shell and a local Terminal via SSH.

6. Populate the name with myvm

Note: You can choose any name you want by replacing myvm with your name throughout this document.

7. Change the “Create in compartment” field to the compartment of your choosing. I’m choosing test Go here to learn how to create a compartment.

8. Scroll down to Networking. In this example we will create a new Virtual Cloud Network (VCN). Change the compartment to the same as you choose above.

9. Scroll down the the “Add SSH keys” section.

10. Select “Paste SSH keys” and paste in the public SSH key created in the cloud shell earlier.

11. You may want to access this VM instance from your local Terminal, press the “+ Another Key”
​ ​ ​​ a. From your local Terminal, generate a new RSA key pair.

​ ​ ​​​ ​ ​​​ ​ ssh-keygen -t rsa -N “” -b 2048 -C “oci_instance” -f ~/.ssh/oci_id_rsa

​ ​ ​​ b. Display the public key and copy it.

​ ​ ​​​ ​ ​​​ ​ cat ~/.ssh/oci_id_rsa.pub

​ ​ ​​ c. In the Create Compute form, paste the public key in the SSH KEYS box. ​ ​ ​​

​ ​ ​​ If you intend to SSH into your instance from any other machine, you may ​ ​ ​click the “+ Another Key” button and enter the public key for that machine.
(you may also want to save a copy of the Cloud Shell private key ‘~/.ssh/id_rsa’ on your local machine.) DO NOT SHARE your private key. This key allows access to your instance.

12. Click “Create” at the bottom of the screen.

13. Once the instance is running, locate the “Public IP sddress” and click Copy.
Keep this IP address handy, it will be referred to as \<YourPublicIP>.

14. In your Cloud Shell create an environment variable to store the IP.

export INSTANCE_IP=<YourPublicIP>

15. In your local Terminal create an environment variable to store the IP.

export INSTANCE_IP=<YourPublicIP>

16. Use SSH to access your instance.
You have a choice connect to your instance from Cloud Shell or from your local terminal.

ssh -i ~/.ssh/oci_id_rsa opc@${INSTANCE_IP}

You now have a VM in the cloud with credentials to access that is always running and ready to setup with all your tools.

This tutorial requires an Oracle Cloud account. You can get one today by signing up for an OCI Free Tier Account.

Join the conversation!

If you’re curious about the goings-on of Oracle Developers in their natural habitat, come join us on our public Slack channel! We don’t mind being your fish bowl 🐠

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chris Bensen

Chris Bensen

I make stuff for myself and Oracle. Creator of the Worlds Largest Raspberry Pi Cluster and Lego Computer.