Add an SSH Key
/sshkey/
You must first generate the required SSH key pairs by using a tool such as ssh-keygen, and then upload the public keys to Compute Classic. For instructions to generate SSH key pairs, see Generating an SSH Key Pair in Using Oracle Cloud Infrastructure Compute Classic.
After adding SSH public keys, you can associate them with instances by specifying the key names in launch plans, as described in Create Instances Using Launch Plans.
Required Role: To complete this task, you must have the Compute_Operations
role. If this role isn't assigned to you or you're not sure, then ask your system administrator to ensure that the role is assigned to you in Oracle Cloud My Services. See Modifying User Roles in Managing and Monitoring Oracle Cloud.
Request
- application/oracle-compute-v3+json
-
Cookie: string
The Cookie: header must be included with every request to the service. It must be set to the value of the set-cookie header in the response received to the POST /authenticate/ call.
object
-
enabled(optional):
boolean
Indicates whether the key must be enabled (default) or disabled. Note that disabled keys cannot be associated with instances.
To explicitly enable the key, specify
true
. To disable the key, specifyfalse
. -
key:
string
The SSH public key value.
-
name:
string
The three-part name of the object (
/Compute-identity_domain/user/object
).Object names can contain only alphanumeric characters, hyphens, underscores, and periods. Object names are case-sensitive.
Response
- application/oracle-compute-v3+json
201 Response
-
set-cookie: string
The cookie value is returned if the session is extended
object
-
enabled(optional):
boolean
Indicates whether the key is enabled (
true
) or disabled. -
key(optional):
string
The SSH public key value.
-
name(optional):
string
The three-part name of the object
-
uri(optional):
string
Uniform Resource Identifier
Examples
cURL Command
The following example shows how to add an SSH key by submitting a POST request on the REST resource using cURL. For more information about cURL, see Use cURL.
Enter the command on a single line. Line breaks are used in this example for readability.
curl -i -X POST -H "Cookie: $COMPUTE_COOKIE" -H "Content-Type: application/oracle-compute-v3+json" -H "Accept: application/oracle-compute-v3+json" -d "@requestbody.json" https://api-z999.compute.us0.oraclecloud.com/sshkey/
-
COMPUTE_COOKIE
is the name of the variable in which you stored the authentication cookie earlier. For information about retrieving the authentication cookie and storing it in a variable, see Authentication. -
api-z999.compute.us0.oraclecloud.com
is an example REST endpoint URL. Change this value to the REST endpoint URL of your Compute Classic site. For information about finding out REST endpoint URL for your site, see Send Requests.
Example of Request Body
The following shows an example of the request body content in the requestbody.json
file.
Some lines may be truncated with ellipses (...) for readability.
{ "enabled": false, "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDzU21CEj6JsqIMQAYwNbmZ5P2BVxA...", "name": "/Compute-acme/jack.jones@example.com/key1" }
Example of Response Body
The following example shows the response body in JSON format.
Some lines may be truncated with ellipses (...) for readability.
{ "enabled": false, "uri": "https://api-z999.compute.us0.oraclecloud.com/sshkey/Compute-acme/jack.jones@example.com/key1", "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDzU21CEj6JsqIMQAYwNbmZ5P2BVxA...", "name": "/Compute-acme/jack.jones@example.com/key1" }