Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function function deletes an SSH key from the server.

Warning:

Only the root account can use this function, and it only affects the root keys. To perform this function on a cPanel user account, call the cPanel API 2 SSH::authkey function through the WHM API.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/deletesshkey?api.version=1&file=%2Froot%2F.ssh%2Ftest&leave_authorized=0
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/deletesshkey?api.version=1&file=%2Froot%2F.ssh%2Ftest&leave_authorized=0
 Command Line
whmapi1 deletesshkey file=%2Froot%2F.ssh%2Ftest leave_authorized=0

Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command. 
  • We introduced this functionality in cPanel & WHM version 11.52.0.8.

 Output (JSON)
{
  "data": {
    "file": "/root/.ssh/test"
  },
  "metadata": {
    "version": 1,
    "reason": "OK",
    "result": 1,
    "command": "deletesshkey"
  }
}
 Output (XML)
<result>
    <data>
        <file>/root/.ssh/test</file>
    </data>
    <metadata>
        <result>1</result>
        <command>deletesshkey</command>
        <reason>OK</reason>
        <version>1</version>
    </metadata>
</result>

Note:

Use WHM's API Shell interface (Home >> Development >> API Shell) to directly test WHM API calls.

   

Parameters

ParameterTypeDescriptionPossible valuesExample
userstringThe SSH key's username.A valid username.username
filestring

Required

The SSH key file's name.

An absolute file path.

/root/.ssh/test
leave_authorizedBoolean

Whether to authorize the SSH key to access the server.

This parameter defaults to 1.

  • 1 — Leave authorized.
  • 0 — Do not leave authorized.
0
              

Returns

ReturnTypeDescriptionPossible valuesExample
filestring

The SSH key file's name.

An absolute path and filename.

/root/.ssh/test