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

 

Description

This function lists the server's SSH keys.

Warning:

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

Examples


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/listsshkeys?api.version=1
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/listsshkeys?api.version=1
 Command Line
whmapi1 listsshkeys

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": {
    "keys": [
      {
        "ctime": null,
        "authorized": 1,
        "comment": "REPO username@example.com",
        "text":
 "ssh-rsa 
XXXXX3XXXX1XX2XXXXXXXXXXXXXXxXXXX6XXXXX90X41X7XXXXX02XXXXX8XXXX54XXXXXXXXXXX2X07XXXXXXXXXXX7XXXX4XXX2X98XXXX98X80XXXXXXX7XX4XXXXxX1XXXXXXXXXXXxXXXXXXXXX6+4XXXX36XXXXX3XXXXXX1XXXXXXXX7+XX1XX6XXXX0XXXXXXX0XXXXXXXXXxX99X7X2XXXXXX03xXXXXX0XXXXXXXXXX9XXXXXXX9XXXXXXXXXXXX/XXXXX07XXXXX3XXXXXX5XXX+XXXXXXXXXXXXX3XxXXXXXXXXXXXX6XXXXXXXXXXXX2XXXXXXXXXXXXXXXXX3XX+XXXX3XXXXXXX== 
 REPO username@example.com",
        "mtime": null,
        "private": 0,
        "file": null
      }
    ]
  },
  "metadata": {
    "version": 1,
    "reason": "OK",
    "result": 1,
    "command": "listsshkeys"
  }
}
 Output (XML)
<result>
    <data>
        <keys>
            <ctime/>
            <authorized>1</authorized>
            <comment>REPO username@example.com</comment>
            <text>
                ssh-rsa
 
XXXXX3XXXX1XX2XXXXXXXXXXXXXXxXXXX6XXXXX90X41X7XXXXX02XXXXX8XXXX54XXXXXXXXXXX2X07XXXXXXXXXXX7XXXX4XXX2X98XXXX98X80XXXXXXX7X/X4XXXXxX1XXXXXXXXXXXxXXXXXXXXX6+4XXXX36XXXXX3XXXXXX1XXXXXXX/X7+XX1XX6XXXX0XXXXXXX0XXXXXXXX+XxX99X7X2XXXXXX03xXXXXX0XXXXXXXXXX9XXXXXXX9XXXXXXXXXXXX/XXXXX07XXXXX3XXXXXX5XXX+/XXXXXXXXXXXXX3XxXXXXXXXXXXXX6XXXXXXXXXXXX2XXXXXXXXXXXXXXXXX3XX+XXXX3XXXXXXX== 
 REPO username@example.com
            </text>
            <mtime/>
            <private>0</private>
            <file/>
        </keys>
    </data>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>listsshkeys</command>
    </metadata>
</result>


Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
userstringA username, to limit the results to keys that the user owns.

A valid username.

username
filesstringA filename, to limit the results to keys that have that filename.A valid filename.TestKey
publicBoolean

Whether to display only public keys.

  • 1 — Display only public keys.
  • 0 — Display all keys.
0
privateBoolean

Whether to display only private keys.

This value defaults to 1.

  • 1 — Display only private keys.
  • 0 — Display all keys.
0
public_texts Boolean

Whether to include public key text.

This value defaults to 0.

  • 1 — Include public key text.
  • 0 — Do not include public key text.
0
private_textBoolean

Whether to include private key text. 

This value defaults to 1.

  • 1 — Include private key text.
  • 0 — Do not include private key text.
0
extract_privateBoolean

Whether to extract and save only the private key.

This value defaults to 0.

  • 1 — Extract and save the private key.
  • 0 — Save all data.
0

Returns

ReturnTypeDescriptionPossible valuesExample
keysarray of hashes

An array of hashes of each key's information.

This hash includes the ctime, authorized, comment, text, mtime, private, file, and encrypted returns.

 

 

ctime

integer

When the key was created.

The function returns this value in the keys hash.

A valid date in Unix time format.1416596824

authorized

Boolean

Whether the key is authorized to access the server.

The function returns this value in the keys hash.

  • 1 — Authorized.
  • 0Not authorized.
0

comment

string

The key's comment.

The function returns this value in the keys hash.

A valid string.REPO username@example.com

text

string

The key's text.

The function returns this value in the keys hash.

A valid key.
 Click to view...
ssh-rsa
 
XXXXX3XXXX1XX2XXXXXXXXXXXXXXxXXXX6XXXXX90X41X7XXXXX02XXXXX8XXXX54XXXXXXXXXXX2X07XXXXXXXXXXX7XXXX4XXX2X98XXXX98X80XXXXXXX7X/X4XXXXxX1XXXXXXXXXXXxXXXXXXXXX6+4XXXX36XXXXX3XXXXXX1XXXXXXX/X7+XX1XX6XXXX0XXXXXXX0XXXXXXXX+XxX99X7X2XXXXXX03xXXXXX0XXXXXXXXXX9XXXXXXX9XXXXXXXXXXXX/XXXXX07XXXXX3XXXXXX5XXX+/XXXXXXXXXXXXX3XxXXXXXXXXXXXX6XXXXXXXXXXXX2XXXXXXXXXXXXXXXXX3XX+XXXX3XXXXXXX== 
 REPO username@example.com

mtime

integer

When the key expires.

The function returns this value in the keys hash.

A valid date in Unix time format.1416596824

private

Boolean

Whether the private key is stored on the server.

The function returns this value in the keys hash.

  • 1 — The private key is on the server.
  • 0 — The private key is not on the server.
1

file

string

The key's filename.

The function returns this value in the keys hash.

A valid filename. TestKey

encrypted

Boolean

Whether the private key is encrypted with a passphrase.

The function returns this value in the keys hash.

  • 1 — Encrypted.
  • 0Not encrypted.
0