SSH from Another Machine to a VM on Oracle Cloud Infrastructure

When you create an instance of VM, you provision it with your RSA public key on the machine where you were working at that time. Let’s imagine a situation where you want to access your VM on OCI but from another machine. Here are the steps you could take.

  1. Start terminal.
  2. Generate an RSA key using ssh-keygen if one doesn’t exist already on another machine where you want to SSH to the VM on OCI from.
  3. Run cat to print the public RSA key to your terminal. Make the public key available to the original machine that you used to access the VM on OCI.
    $ cat ~/.ssh/
  4. From the original machine where you already have an access to the VM on OCI, SSH to the VM.
    $ ssh opc@[the public IP address]
  5. Edit the file ~/.ssh/authorized_keys with vi.
    $ vi ~/.ssh/authorized_keys
  6. There should already be RSA public key in the file for your machine. Add the RSA key generated in step 3.

    Sorry if the image above is hard to comprehend. The text from the cursor below is the RSA public key for the new machine you want to access the OCI VM from.
  7. Save it and access the VM from the new machine.
    $ ssh opc@[the public IP address]


By adding public RSA key to authorized_keys file under ~/.ssh directory, you can access to the VM from another machine.

Leave a Reply

Your email address will not be published.