You may want to access an existing instance from another client machine that has a different public/private key pair on Oracle Cloud Infrastructure. I looked around the net and I could not find a solid documentation on how to do it. Basically, the OCI console itself does not have a support to add another public key.
I thought of my previous post on passwordless SSH article. Basically, you are adding public key to ~/.ssh/authorized_keys so that whoever has the public key in the list can SSH into it. I tried adding a new public key to
~/.ssh/authorized_keys on an existing instance and it was successful. I will describe the steps below.
- On a new client machine, execute
ssh-keygento generate a new public/private key pair. If you have already done it, you can skip this step.
- It generates
~/.ssh/id_rsa(private key) and
- Print the public key on your terminal by executing cat
- Copy the public key to the machine that you already have access to the instance. You could email it to yourself or use something like DropBox.
- SSH into your existing instance.
- Open authorized_keys file.
- Copy the new public key and paste it in the last line.
- Save the file and exit vim. (:wq)
- Go back to the machine where you generated the public key.
- SSH into the machine now and you now have access to the instance.
This method probably can be applied to other cloud services as well as long as you have a Linux distro instance.