You can find our user documentation at docs.cpanel.net.

Check out our new API beta site!

Child pages
  • WHM API 1 Functions - generatesshkeypair
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&passphrase=123456luggage&name=TestKey&bits=1024&algorithm=dsa&abort_on_existing_key=0&comment=NoComment
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/generatesshkeypair?api.version=1&passphrase=123456luggage&name=TestKey&bits=1024&algorithm=dsa&abort_on_existing_key=0&comment=NoComment
 Command Line
whmapi1 generatesshkeypair passphrase=123456luggage name=TestKey bits=1024 algorithm=dsa abort_on_existing_key=0 comment=NoComment


Notes:

  • Unless otherwise noted, 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.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{ 
   "data":{ 
      "name":"TestKey",
      "fingerprint":null
   },
   "metadata":{ 
      "reason":"OK",
      "result":1,
      "command":"generatesshkeypair",
      "version":1
   }
}
 Output (XML)
<result>
    <data>
       <fingerprint null="true" />
       <name>TestKey</name>
    </data>
    <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
passphrasestring

The key's passphrase.

This parameter defaults to an empty string.

A secure passphrase.123456luggage
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.1024
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 an empty string.

A valid string.NoComment

Returns

ReturnTypeDescriptionPossible valuesExample
name stringThe key's filename.A valid filename.KeyFile 
fingerprint string

The key's MD5 fingerprint.

  • A valid MD5 value.
  • null 
null