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

 

Description

This function generates an SSH key pair.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/generatesshkeypair?api.version=1&user=username&passphrase=12345luggage&name=TestKey&bits=2048&algorithm=dsa&abort_on_existing_key=0&comment=NoComment
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/generatesshkeypair?api.version=1&user=username&passphrase=12345luggage&name=TestKey&bits=2048&algorithm=dsa&abort_on_existing_key=0&comment=NoComment
 Command Line
whmapi1 generatesshkeypair user=username passphrase=12345luggage name=TestKey bits=2048 algorithm=dsa abort_on_existing_key=0 comment=NoComment

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)
{
  "metadata": {
    "result": 0,
    "version": 1,
    "command": "generatesshkeypair",
    "reason": null
  }
}
 Output (XML)
<result>
    <metadata>
        <result>0</result>
        <version>1</version>
        <command>generatesshkeypair</command>
        <reason/>
    </metadata>
</result>

Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
userstring

The key's owner.

This parameter defaults to the root user.

A valid username.

username
passphrasestring

The key's passphrase.

This parameter defaults to a blank string.

A secure passphrase.12345luggage
namestring

The key's filename.

This parameter defaults to id_rsa if the algorithm is rsa and to id_dsa if the algorithm is dsa.

A valid filename.KeyFile
bitsinteger

The key's bits.

This parameter defaults to 4096 if the algorithm is rsa and 1024 if the algorithm is dsa.

A valid positive integer.2048
algorithmstring

The key's encryption algorithm.

The parameter defaults to the system's default algorithm.

  • dsa
  • rsa2
dsa
abort_on_existing_keyBoolean

Whether to abort the function if the user already has a key.

This parameter always passes 1.

  • 1 — Abort.
  • 0 — Continue.
0
commentstring

A comment.

This parameter defaults to a blank string.

A valid string.NoComment

Returns

This function only returns metadata.