Child pages
  • GPG::generate_key
Skip to end of metadata
Go to start of metadata

Description

This function generates a GnuPG key. The system saves the key in the user's .gnupg directory.

Note:

This function uses the system's entropy to generate the key. Systems with low entropy levels may cause long generation times or timeouts.


Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/GPG/generate_key?email=user@example.com&name=testkey


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Generate a GnuPG key.
$poll = $cpanel->uapi(
    'GPG', 'generate_key',
    array(
        'name' => 'testkey',
		'email' => 'user@example.com'
  )
);


Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
#  Generate a GnuPG key.
my $poll = $cpliveapi->uapi(
    'GPG', 'generate_key',
    {
        'name' => 'testkey',
		'email' => 'user@example.com'
  }
);


Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Template Toolkit
<!-- Generate a GnuPG key. -->
[% execute('GPG', 'generate_key', { 'name' => 'testkey','email'=>'user@example.com' } ) %]


Note:

For more information, read our Guide to Template Toolkit documentation. 

 Command Line
uapi --user=username GPG generate_key name=testkey email=user@example.com
 Output (JSON)
{
  "data":[
  ],
  "errors": null,
  "messages": null,
  "metadata":{
  },
  "status": 1,
  "warnings": null
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
namestring

Required

The name of the user for whom to generate the key.

Any string that contains at least five characters.testkey
commentstring

A comment about the key.

This parameter defaults to null.

Any string.

TestKey's Key
emailstring

Required

The user's email address.

A valid email address.user@example.com
expirestring

The desired expiration date of the key

This parameter defaults to one year from the current date.

A valid Unix timestamp.
1560363242
no_expire BooleanWhether to generate the key without an expiration date.
  • 1 — The key will never expire.
  • 0 — The key will use the expire parameter to determine its expiration date.
0 
keysizeinteger

The new key's size, in bytes.

Note:

Large keys require more time to generate. 

This parameter defaults to 2048.

  • 1024
  • 2048
  • 3072
  • 4096
2048
passphrasestring

The key's password.

This parameter defaults to null.

A secure password.12345luggage

Returns

This function only returns metadata.