Managing SSH Keys

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

add sshkey

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

Syntax

oracle-compute add sshkey name key [--osuser] [--enabled]

Parameters and Options

The following parameters are specific to this command. You can also use the common options described in General Command Options.

Parameter Description
name Name of the SSH key.

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

key Name of the file that contains the value of the SSH public key
--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.
--enabled (Optional) Specifies if the key is enabled or disabled. Default value is True.

Example

oracle-compute add sshkey /mytenant/public/sshkey id_rsa.pub -f json

Sample Output

$ oracle-compute add sshkey /mytenant/public/sshkey id_rsa.pub -f json

{"list": 
        [ {  
        "osuser": "",  
        "enabled": true,  
        "uri": "http://api/sshkey/mytenant/public/sshkey",  
        "key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEo.....==\n-----END RSA PRIVATE KEY-----",  
        "name": "/mytenant/public/sshkey" 
        } ]
}

delete sshkey

This command enables you to delete a specific SSH key.

Syntax

oracle-compute delete sshkey name

Parameters and Options

The following parameters are specific to this command. You can also use the common options described in General Command Options.

Parameter Description
name Name of the SSH key to be deleted

Example

$ oracle-compute delete sshkey /mytenant/public/sshkey 

update sshkey

This command enables you to update information for a specific SSH key.

Syntax

oracle-compute update sshkey name [--key] [--enabled] [--osuser]

Parameters and Options

The following parameters are specific to this command. You can also use the common options described in General Command Options.

Parameter Description
name Name of the SSH key
--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.
--osuser (Optional) Operating system user to which this key will be assigned.

Example

$ oracle-compute -u /mytenant/user update sshkey /mytenant/public/sshkey --enabled false

Sample Output

$  oracle-compute -u /mytenant/user update sshkey /mytenant/public/sshkey --enabled false  -f json
{
 "list": [
  {
   "osuser": "",
   "enabled": false,
   "uri": "http://api.oc.example.com/sshkey/mytenant/public/sshkey",
   "key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEo.....==\n-----END RSA PRIVATE KEY-----",
   "name": "/mytenant/public/sshkey"
  }
 ]
}

download sshkey

This command enables you to download a specific SSH key.

Syntax

oracle-compute download sshkey name sshkey

Parameters and Options

The following parameters are specific to this command. You can also use the common options described in General Command Options.

Parameter Description
name Name of the SSH key to be downloaded
sshkey Name of a local file to store the downloaded key

Example

oracle-compute download sshkey /mytenant/public/sshkey sshkey.pub

Retrieve SSH Key Details

You can retrieve SSH Key details by using the CLI.

discover sshkey

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

Syntax

oracle-compute discover sshkey container

Parameters and Options

The following parameters are specific to this command. You can also use the common options described in General Command Options.

Parameter Description
container Hierarchical name-space for the SSH key

Example

$ oracle-compute discover sshkey /mytenant/public

Sample Output

$ oracle-compute discover sshkey /mytenant/public
entry
/mytenant/public/user1_key1
/mytenant/public/root_key1

get sshkey

This command enables you to retrieve key information for a specific tenant or user.

Syntax

oracle-compute get sshkey name

Parameters and Options

The following parameters are specific to this command. You can also use the common options described in General Command Options.

Parameter Description
name Name of SSH key, for which information must be retrieved

Example

$ oracle-compute get sshkey /mytenant/public/root_key1

Sample Output

$ oracle-compute get sshkey /mytenant/public/root_key1 -Fname,osuser
name                                   osuser
/mytenant/public/root_key1             root

list sshkey

This command enables you to list SSH Key information in a specific container and subcontainers.

Syntax

oracle-compute list sshkey container [--name]

The following parameters are specific to this command. You can also use the common options described in General Command Options.

Parameter Description
container Hierarchical name-space for SSH key
--name

(Optional) Name of SSH Key, for which information must be retrieved

Example

oracle-compute list sshkey /mytenant/public/

Sample Output

$ oracle-compute list sshkey /mytenant/public/ -F name,osuser
name                                              osuser
/mytenant/public/user1_key1                       oracle
/mytenant/public/root_key1                        root