+1 vote
in Operating Systems by (64.6k points)
When I created the Oracle VM instance, I added only my local machine's public key to log in without a password. Now, I want to add some other machines' public keys so that I can also log in from those machines without a password. How can I add an additional key, as I do not see any option on their Cloud GUI?

1 Answer

+3 votes
by (359k points)
selected by
 
Best answer

It is a very easy process to add an SSH public key to an Oracle VM instance. You do not need to use their GUI, you can do it from the command line. Follow these steps:

Step 1: Copy the Public Key from Your Local Machine

  • On your local machine, copy the contents of your public SSH key by running the following command in your terminal. If your public key is stored in a different location, replace "~/.ssh/id_rsa.pub" with the correct file path.

cat ~/.ssh/id_rsa.pub

Step 2: Connect to the Oracle VM Instance

  • Use SSH to connect to your Oracle VM instance from your local machine. Replace <instance-public-IP> with the public IP address of your Oracle VM instance.

ssh username@<instance-public-IP>

Step 3: Add the Public Key to the authorized_keys File

  • On the Oracle VM instance, open the authorized_keys file in edit mode:

sudo nano ~/.ssh/authorized_keys

  •  Paste the public key you copied in Step 1 into the file. If the file already contains other keys, append the new key to a new line to avoid overwriting the existing keys.
  • Save and exit the editor
  • Reboot the instance from Oracle's VM instance GUI.

Now you can log in to VM from this new machine.


...