Child pages
  • UAPI Functions - GPG::import_key
Skip to end of metadata
Go to start of metadata

Description

This function imports a GnuPG (GPG) key.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/GPG/import_key?key_data=%0A-----BEGIN%20PGP%20PUBLIC%20KEY%20BLOCK-----%0AVersion%3A%20GnuPG%20v2.0.14%20(GNU%2FLinux)%0A%0AmQENBFN0%2BOsBCADoFvyf8gHIKZ%2F%2B5KwbWb3Ht%2Fz1ukyQqFNGpBVIqHossmjmyF9e%0APn6iiZ0fHnt7r6XGGXaP%2BKKjIxAcqOTiFiP%2BHIx6GQubzVih6Ol0YNjzmK%2Ft4f%2B4%0AfSElEVnyzeyJa4LmC%2Fui%2FvvtptJ8JX6su7f11BwUTSyuqnk204AfN5uVpAcZNPT0%0A0qNNky1bxYvPUxU6Imvi1q3NtpFzqsQ4u%2FyZuLpUe7uwmgMPeO0lAms1kCa3Guot%0A3mfSt0vrUAMdcV4drY1FGtYZdYSa4rSTzpFuB7o9Ze%2BE3fUbCWs1%2B0FiN3JQNGO1%0AS2lnqjEqbpz2nHtA50elJRGqxZLEi8zkFqlTABEBAAG0Z2NQYW5lbCBTZWN1cml0%0AeSBUZWFtIC0gVEVTVCAoVEhJUyBJUyBBIFRFU1QgS0VZOyBETyBOT1QgVVNFIEZP%0AUiBBTllUSElORyBSRUFMISkgPHNlY3RlYW1zaXhAY3BhbmVsLm5ldD6JAT4EEwEC%0AACgFAlN0%2BOsCGwMFCQHhM4AGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOhU%0A60c9RtoRkhMIAIe2yDKj55mGD3zbuGqxx6NNNIyiuEujw31N8yOS9BKTqGtIiK9i%0AGu4lzrzmHISKi0rjKmJdbckap7OouUoo9WR3ewjN6S5EHyjKfrrMwMzTWMPZOkTj%0A7A698X0vGc9yZ6KyBj8mM8J9duvNtRS285hfXfQxYO%2FuiyrJGBedI%2FWVZ3a7mcfq%0A7FhC8t6jU6sz9uIvYHAzywcVdmhEK5rS%2FuE%2F9e37h46jn2%2BkzlIWEe%2FYgpa%2BuWdT%0AO%2BOyqteW51LEjXLWMyP8AJEq8EoqbqKnm4Q1g0etOQ9trrkLUnPxaSwD5R6i4KLH%0AMR%2Fh7m%2FOoz8yOhUlrCGJwX7v9qDEdaYYFLQ%3D%0A%3DMEFZ%0A-----END%20PGP%20PUBLIC%20KEY%20BLOCK-----%0A


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.
 
$key = <<<'ENDKEY'
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.14 (GNU/Linux)
 
mQENBFN0+OsBCADoFvyf8gHIKZ/+5KwbWb3Ht/z1ukyQqFNGpBVIqHossmjmyF9e
Pn6iiZ0fHnt7r6XGGXaP+KKjIxAcqOTiFiP+HIx6GQubzVih6Ol0YNjzmK/t4f+4
fSElEVnyzeyJa4LmC/ui/vvtptJ8JX6su7f11BwUTSyuqnk204AfN5uVpAcZNPT0
0qNNky1bxYvPUxU6Imvi1q3NtpFzqsQ4u/yZuLpUe7uwmgMPeO0lAms1kCa3Guot
3mfSt0vrUAMdcV4drY1FGtYZdYSa4rSTzpFuB7o9Ze+E3fUbCWs1+0FiN3JQNGO1
S2lnqjEqbpz2nHtA50elJRGqxZLEi8zkFqlTABEBAAG0Z2NQYW5lbCBTZWN1cml0
eSBUZWFtIC0gVEVTVCAoVEhJUyBJUyBBIFRFU1QgS0VZOyBETyBOT1QgVVNFIEZP
UiBBTllUSElORyBSRUFMISkgPHNlY3RlYW1zaXhAY3BhbmVsLm5ldD6JAT4EEwEC
ACgFAlN0+OsCGwMFCQHhM4AGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOhU
60c9RtoRkhMIAIe2yDKj55mGD3zbuGqxx6NNNIyiuEujw31N8yOS9BKTqGtIiK9i
Gu4lzrzmHISKi0rjKmJdbckap7OouUoo9WR3ewjN6S5EHyjKfrrMwMzTWMPZOkTj
7A698X0vGc9yZ6KyBj8mM8J9duvNtRS285hfXfQxYO/uiyrJGBedI/WVZ3a7mcfq
7FhC8t6jU6sz9uIvYHAzywcVdmhEK5rS/uE/9e37h46jn2+kzlIWEe/Ygpa+uWdT
O+OyqteW51LEjXLWMyP8AJEq8EoqbqKnm4Q1g0etOQ9trrkLUnPxaSwD5R6i4KLH
MR/h7m/Ooz8yOhUlrCGJwX7v9qDEdaYYFLQ=
=MEFZ
-----END PGP PUBLIC KEY BLOCK-----
ENDKEY;
 
// Import a GnuPG key.
$poll = $cpanel->uapi(
  'GPG', 'import_key',
      array(
          'key_data' => $key,
    )
);


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.
 
# Import GnuPG key.
my $poll = $cpliveapi->uapi(
    'GPG', 'import_key',
    {
        'key_data' => '%0A-----BEGIN%20PGP%20PUBLIC%20KEY%20BLOCK-----%0AVersion%3A%20GnuPG%20v2.0.14%20(GNU%2FLinux)%0A%0AmQENBFN0%2BOsBCADoFvyf8gHIKZ%2F%2B5KwbWb3Ht%2Fz1ukyQqFNGpBVIqHossmjmyF9e%0APn6iiZ0fHnt7r6XGGXaP%2BKKjIxAcqOTiFiP%2BHIx6GQubzVih6Ol0YNjzmK%2Ft4f%2B4%0AfSElEVnyzeyJa4LmC%2Fui%2FvvtptJ8JX6su7f11BwUTSyuqnk204AfN5uVpAcZNPT0%0A0qNNky1bxYvPUxU6Imvi1q3NtpFzqsQ4u%2FyZuLpUe7uwmgMPeO0lAms1kCa3Guot%0A3mfSt0vrUAMdcV4drY1FGtYZdYSa4rSTzpFuB7o9Ze%2BE3fUbCWs1%2B0FiN3JQNGO1%0AS2lnqjEqbpz2nHtA50elJRGqxZLEi8zkFqlTABEBAAG0Z2NQYW5lbCBTZWN1cml0%0AeSBUZWFtIC0gVEVTVCAoVEhJUyBJUyBBIFRFU1QgS0VZOyBETyBOT1QgVVNFIEZP%0AUiBBTllUSElORyBSRUFMISkgPHNlY3RlYW1zaXhAY3BhbmVsLm5ldD6JAT4EEwEC%0AACgFAlN0%2BOsCGwMFCQHhM4AGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOhU%0A60c9RtoRkhMIAIe2yDKj55mGD3zbuGqxx6NNNIyiuEujw31N8yOS9BKTqGtIiK9i%0AGu4lzrzmHISKi0rjKmJdbckap7OouUoo9WR3ewjN6S5EHyjKfrrMwMzTWMPZOkTj%0A7A698X0vGc9yZ6KyBj8mM8J9duvNtRS285hfXfQxYO%2FuiyrJGBedI%2FWVZ3a7mcfq%0A7FhC8t6jU6sz9uIvYHAzywcVdmhEK5rS%2FuE%2F9e37h46jn2%2BkzlIWEe%2FYgpa%2BuWdT%0AO%2BOyqteW51LEjXLWMyP8AJEq8EoqbqKnm4Q1g0etOQ9trrkLUnPxaSwD5R6i4KLH%0AMR%2Fh7m%2FOoz8yOhUlrCGJwX7v9qDEdaYYFLQ%3D%0A%3DMEFZ%0A-----END%20PGP%20PUBLIC%20KEY%20BLOCK-----%0A',
  }
);


Note:

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

 Command Line
uapi --user=username GPG import_key key_data='%0A-----BEGIN%20PGP%20PUBLIC%20KEY%20BLOCK-----%0AVersion%3A%20GnuPG%20v2.0.14%20(GNU%2FLinux)%0A%0AmQENBFN0%2BOsBCADoFvyf8gHIKZ%2F%2B5KwbWb3Ht%2Fz1ukyQqFNGpBVIqHossmjmyF9e%0APn6iiZ0fHnt7r6XGGXaP%2BKKjIxAcqOTiFiP%2BHIx6GQubzVih6Ol0YNjzmK%2Ft4f%2B4%0AfSElEVnyzeyJa4LmC%2Fui%2FvvtptJ8JX6su7f11BwUTSyuqnk204AfN5uVpAcZNPT0%0A0qNNky1bxYvPUxU6Imvi1q3NtpFzqsQ4u%2FyZuLpUe7uwmgMPeO0lAms1kCa3Guot%0A3mfSt0vrUAMdcV4drY1FGtYZdYSa4rSTzpFuB7o9Ze%2BE3fUbCWs1%2B0FiN3JQNGO1%0AS2lnqjEqbpz2nHtA50elJRGqxZLEi8zkFqlTABEBAAG0Z2NQYW5lbCBTZWN1cml0%0AeSBUZWFtIC0gVEVTVCAoVEhJUyBJUyBBIFRFU1QgS0VZOyBETyBOT1QgVVNFIEZP%0AUiBBTllUSElORyBSRUFMISkgPHNlY3RlYW1zaXhAY3BhbmVsLm5ldD6JAT4EEwEC%0AACgFAlN0%2BOsCGwMFCQHhM4AGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOhU%0A60c9RtoRkhMIAIe2yDKj55mGD3zbuGqxx6NNNIyiuEujw31N8yOS9BKTqGtIiK9i%0AGu4lzrzmHISKi0rjKmJdbckap7OouUoo9WR3ewjN6S5EHyjKfrrMwMzTWMPZOkTj%0A7A698X0vGc9yZ6KyBj8mM8J9duvNtRS285hfXfQxYO%2FuiyrJGBedI%2FWVZ3a7mcfq%0A7FhC8t6jU6sz9uIvYHAzywcVdmhEK5rS%2FuE%2F9e37h46jn2%2BkzlIWEe%2FYgpa%2BuWdT%0AO%2BOyqteW51LEjXLWMyP8AJEq8EoqbqKnm4Q1g0etOQ9trrkLUnPxaSwD5R6i4KLH%0AMR%2Fh7m%2FOoz8yOhUlrCGJwX7v9qDEdaYYFLQ%3D%0A%3DMEFZ%0A-----END%20PGP%20PUBLIC%20KEY%20BLOCK-----%0A'


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
    "apiversion": 3,
    "module": "GPG",
    "func": "import_key",
    "result": {
        "messages": null,
        "data": {
            "key_id": "59E79B6904616529"
        },
        "errors": 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
key_datastring

Required

The key to import.

A GPG key.

Note:

You must URI-encode this value.

 Click to view...
%0A-----BEGIN%20PGP%20PUBLIC%20KEY%20BLOCK-----%0AVersion%3A%20GnuPG%20v2.0.14%20(GNU%2FLinux)%0A%0AmQENBFN0%2BOsBCADoFvyf8gHIKZ%2F%2B5KwbWb3Ht%2Fz1ukyQqFNGpBVIqHossmjmyF9e%0APn6iiZ0fHnt7r6XGGXaP%2BKKjIxAcqOTiFiP%2BHIx6GQubzVih6Ol0YNjzmK%2Ft4f%2B4%0AfSElEVnyzeyJa4LmC%2Fui%2FvvtptJ8JX6su7f11BwUTSyuqnk204AfN5uVpAcZNPT0%0A0qNNky1bxYvPUxU6Imvi1q3NtpFzqsQ4u%2FyZuLpUe7uwmgMPeO0lAms1kCa3Guot%0A3mfSt0vrUAMdcV4drY1FGtYZdYSa4rSTzpFuB7o9Ze%2BE3fUbCWs1%2B0FiN3JQNGO1%0AS2lnqjEqbpz2nHtA50elJRGqxZLEi8zkFqlTABEBAAG0Z2NQYW5lbCBTZWN1cml0%0AeSBUZWFtIC0gVEVTVCAoVEhJUyBJUyBBIFRFU1QgS0VZOyBETyBOT1QgVVNFIEZP%0AUiBBTllUSElORyBSRUFMISkgPHNlY3RlYW1zaXhAY3BhbmVsLm5ldD6JAT4EEwEC%0AACgFAlN0%2BOsCGwMFCQHhM4AGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOhU%0A60c9RtoRkhMIAIe2yDKj55mGD3zbuGqxx6NNNIyiuEujw31N8yOS9BKTqGtIiK9i%0AGu4lzrzmHISKi0rjKmJdbckap7OouUoo9WR3ewjN6S5EHyjKfrrMwMzTWMPZOkTj%0A7A698X0vGc9yZ6KyBj8mM8J9duvNtRS285hfXfQxYO%2FuiyrJGBedI%2FWVZ3a7mcfq%0A7FhC8t6jU6sz9uIvYHAzywcVdmhEK5rS%2FuE%2F9e37h46jn2%2BkzlIWEe%2FYgpa%2BuWdT%0AO%2BOyqteW51LEjXLWMyP8AJEq8EoqbqKnm4Q1g0etOQ9trrkLUnPxaSwD5R6i4KLH%0AMR%2Fh7m%2FOoz8yOhUlrCGJwX7v9qDEdaYYFLQ%3D%0A%3DMEFZ%0A-----END%20PGP%20PUBLIC%20KEY%20BLOCK-----%0A

Returns

ParameterTypeDescriptionPossible valuesExample
key_idstring

The key's ID.

A valid string.

59E79B6904616529