oracle/oci-typescript-sdk

How to add ssh keys when using launch_instance

Closed this issue · 4 comments

Hey there Oracle team. I am using your Javascript SDK and have been successful in launching an instance on OCI. However, I am not able to figure out for the life of me how to add my ssh keys to the instance through the API. I need to add my SSH keys to the instance I am launching to complete my automation task.

In the Python SDK you can do this. Thank you for your help!

Hi @vamman ,

Can you please share the API you used to add the SSH keys for Python SDK? That could help us investigate if there is an issue in Javascript SDK or not.

Thanks.

Sure.

https://github.com/oracle/oci-python-sdk/blob/master/examples/launch_instance_example.py
https://github.com/oracle/oci-python-sdk/blob/00cd57d72b7095cba79fa1fe04bb936dae67c3d6/src/oci/core/models/launch_instance_details.py

There is a parameter in the instance metadata to specify the authorized ssh keys. I can not find a similar method in this SDK.

We need to attach the ssh key with the instance launching. I am sure there is a way but it is not obvious from the docs.

Thanks @vamman .

Can you please refer to this API - https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/Instance/LaunchInstance

There is a Typescript SDK sample on the page -> https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/Instance/LaunchInstance:~:text=Go%20SDK-,TypeScript,-SDK

The typescript example also has a metadata attribute from which you can specify your ssh keys. Note that the metadata value in the typescript example is not real. You can refer to this link to provide the correct metadata value. -> https://docs.oracle.com/en-us/iaas/api/#/en/iaas/20160918/datatypes/LaunchInstanceDetails:~:text=Type%3A%20LaunchOptions-,metadata,-Required%3A%20no

Let me know if that works.

Hi @vamman , I am closing this issue for now based on the resources shared in my above comment. Please feel free to re-open if you run into the issue again.