Description

This function authorizes an SSH key.

Examples 


https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=SSH&cpanel_jsonapi_func=authkey&key=user&action=authorize

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Authorize the SSH key for "user"
$list_key = $cpanel->api2(
    'SSH', 'authkey', 
    array(
        'key' => 'user',
        'action' => 'authorize',
 ) 
);

 

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Authorize the SSH key for "user"
my $authorize_key = $cpliveapi->api2(
    'SSH', 'authkey',
    {
        'key' => 'user',
        'action' => 'authorize',
    }
);

 

cpapi2 --user=username SSH authkey key=user action=authorize

{
  "cpanelresult": {
    "apiversion": 2,
    "func": "authkey",
    "data": [
      {
        "status": "authorized",
        "name": "user.pub"
      }
    ],
    "event": {
      "result": 1
    },
    "module": "SSH"
  }
}

   

Parameters

ParameterTypeDescriptionPossible valuesExample
keystring

Required

The SSH key's filename.

A valid string.

The following names are reserved:

  • config
  • known_hosts
  • authorized_keys
  • environment
  • rc
  • identity
user
actionstring

Required

Whether to authorize or deauthorize the key.

  • authorize — Authorize the key.
  • deauthorize — Deauthorize the key.
authorize

Returns

ReturnTypeDescriptionPossible valuesExample
namestring

The SSH key's filename.

A string that contains the fingerprint and file location.user.pub
statusstringThe SSH key's status.
  • authorized
  • deauthorized
authorized
reasonstring

A reason for failure.

This function only returns a reason value if it failed.

A string that describes the error.

This is an error message.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1