Managing SSH Keys

You can automate the login process to instances by using the SSH keys.

Add Public SSH Key

This API enables you to import a new public SSH key and associate it to a user.

Method

POST

REST Resource

/sshkey

URI

https://api_endpoint/sshkey/

Request Body Parameters

Parameter Description
name Name of the SSH key.

Object names can contain only alphanumeric characters, hyphens, and periods. Object names are case-sensitive.

key SSH public key value
enabled (Optional) Specifies if the SSH key is enabled or disabled.  The default value is True.
osuser (Optional) Operating system user to which this key will be assigned.  If this option is not specified, no key is installed in the VM.

Example URI

https://api.oc.example.com/sshkey/

Example Request Body

{
        "osuser": "oracle", 
        "enabled": true,
        "key": "ssh-rsa AA16hLNo4kWmYslf....leo@t410....",
        "name": "/mytenant/public/oracle_key1"
}

Example Response Body

{
        "osuser": "oracle", 
        "enabled": true, 
        "uri": "https://api/sshkey/mytenant/public/oracle_key1", 
        "key": "ssh-rsa AA16hLNo4kWmYslf....leo@t410....", 
        "name": "/mytenant/public/oracle_key1"
}

Delete SSH Key

This API enables you to delete a specific SSH key.

Method

DELETE

REST Resource

/sshkey/name

URI

https://api_endpoint/sshkey/name

URI Parameter

Parameter Description
name Name of the SSH key to be deleted

Example URI

https://api.oc.example.com/sshkey/mytenant/public/key1

Update SSH Key

This API enables you to update/overwrite the key, the enabled field, and the osuser field for a specific SSH key.

Method

PUT

REST Resource

/sshkey/name

URI

https://api_endpoint/sshkey/name

URI Parameter

Parameters Description
name Name of the SSH key

Request Body Parameters

Parameters Description
key (Optional) Name of the file that contains the value of the SSH public key
enabled (Optional) Specifies if the key is enabled or disabled. The default value is True
osuser (Optional) OS user to which this key will be assigned

Example URI

https://api.oc.example.com/sshkey/mytenant/public/myuser

Example Request Body

{
        "osuser": "myuser"
        "enabled": true,
        "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0ibAEmysI4o1zf...",
        "name": "/mytenant/public/myuser"
}

Example Response Body

{
        "osuser": "myuser"
        "enabled": true,
        "uri": "https://api.oc.example.com/sshkey/mytenant/public/myuser",
        "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0ibAEmysI4o1zfb4dOJIyaN67pya8A...",
        "name": "/mytenant/public/myuser"
}

Retrieve SSH Key Details

You can retrieve SSH Key details by using the REST API.

Discover SSH Keys

This API enables you to discover SSH keys in a specific container and subcontainer.

Note:

The discover API calls display the names of the objects in the specified container, not the details about the objects. To list the names of the objects, you must set the Accept header to application/oracle-compute-v3+directory+json. For all other purposes, you must set the Accept header to application/oracle-compute-v3+json.

Method

GET

REST Resource

/sshkey/container/

URI

https://api_endpoint/sshkey/container/

URI Parameter

Parameter Description
container Hierarchical namespace for SSH key

Example URI

https://api.oc.example.com/sshkey/mytenant/public/

Example Response Data

{
  "result": [
    "/mytenant/public/adminkey",
    "/mytenant/public/permkey",
    "/mytenant/public/tempkey"
  ]
}

Get SSH Key

This API enables you to retrieve information for a specific SSH key..

Method

GET

REST Resource

/sshkey/name

URI

https://api_endpoint/sshkey/name

URI Parameter

Parameter Description
name Name of the SSH key, for which information is retrieved

Example URI

https://api.oc.example.com/sshkey/mytenant/public/oracle_key1

Example Response Data

{
        "osuser": "oracle", 
        "enabled": true, 
        "uri": "https://api/sshkey/mytenant/public/oracle_key1", 
        "key": "ssh-rsa AAAAB3LNo4kWmYslf...leo@t410.....", 
        "name": "/mytenant/public/oracle_key1"
}

List SSH Keys

This API enables you to list SSH key information in a specific container and subcontainer.

Method

GET

REST Resource

/sshkey/container/

URI

https://api_endpoint/sshkey/container/

URI Parameter

Parameter Description
container Hierarchical namespace for the SSH key

Example URI

https://api.oc.example.com/sshkey/mytenant/public/myuser

Example Response Data

{
        "osuser": "myuser",
        "enabled": true,
        "uri": "https://api.oc.example.com/sshkey/mytenant/public/myuser",
        "key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0ibAEmysI4o1zfb4dOJIyaN67pya8A...AWS",
        "name": "/mytenant/public/myuser"
}