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

 

Description

This function imports an SSH key.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/importsshkey?api.version=1&name=TestKey&user=username&key=-----BEGIN%20RSA%20PRIVATE%20KEY-----%0AMIIEpQIBAAKCAQEAqc%2FSzmxPfzQtXfLRfYP59M%2Bh33BHIH8tbRiM483hDLd6ZPs1%0ABGaDcZus5HMmddVjjfL5GqTdmf2pElXaBXYrbFy8AU6fQfm254NLUgrWw0JTLfl0%0ACu4L0YfrTbuOmhKT1Fj2OxAMBlpahc%2BYvmThYbV%2FiofRLLWfOBDqwm2tIc0RwB47%0AlSVq8njy05sazQ1QEVSt6GD1d%2BlHOcj%2Ba9N96B1M9cC9N3oy%2BdHbDFC5Zj6nEuov%0AZstv5EWX49yZuimczpeqJXTmf4mp882TK0dq%2B6v%2BocVxAoqXMc94cTIyxc0cU2CQ%0AbvbrBUjvOO8iJgBFDAX%2BnKtbwd011ckdfzgWrQIDAQABAoIBAQCGwSQRqUPgtuA1%0AiKaTyzKFAmv7axcWg7XhuDS95jfsJoHbNroY1t0CP76Qv4xKv96z25ewfBpaxD%2Fy%0AC%2Bzqnp7Q7DpJc0HQUkDCMZ%2BI6I8K%2FkwR1L4wmj0ItqqU0fzU6V8kiMBFmHNiazsg%0AquAUXuu35RbkMOleaHaEQHB7gBt%2FEPhFe3%2FudkwpKq%2B%2FZ%2FhEJmgTqTFA988a9ZyU%0AJODL7bCAbw5InUmz4QdX%2BRQZqKzNUcjWFE7%2FziuxS%2BKkQFlc%2FoG%2FQYOuA0uTc3iU%0AWwX3TISnrI%2F7DwM%2Fpb4sEhpOv2fr1AS%2F2HmjcYWxh3hdQkBW0NUW3kY65q43Mfj4%0AdiEVDSbhAoGBAOHn7HPXVGIC8Z26Trzig%2BeXuFxq0sHW6E39KcGVDfN7yfpP%2BCyZ%0AWkJ9SA6u4u3Fi8%2BPNyNBDcTDERvSlAKEfQkVQJLMAP1eo6ngiqXz6tCpOyCwFLNz%0A63P32axYCGRXrzlWTJfJdimfZHymxVJN2t38V1fUKJB6aQrelmU359WJAoGBAMBu%0A6373%2B8w668yf2pjCE3xSZvq98Lp1vLd8AXW1Y%2B6af%2Fm3SOVHB2UoVBWlb2DPta5q%0A%2BnOccGxqdSGJ6YuwhL8DSxNu%2BoakYDqGW%2FmnUxfLHiM9IZ%2Fqf6AMxqTCVBJkjEET%0Ahy2RWYw50PcUKUhBjwsA9R7Lt0Gu%2BKJU%2F8jx6dMFAoGBAL%2F76edIyF3DQrNY8jF0%0AD8VyGyvvXM1%2FZk1hKWtq0UBro2snKzI74YlAD0zrM8%2F%2BYqMygxli3%2BCoJpIOk9rP%0A3bMqbIZU%2BUJae5yTR0Fh2d0a9TUCb5VSnncf282rwvYDztZbkRwuCk21OCD3Whpo%0AL%2BkX2uK5Wv%2FuB%2FdE02uR52SBAoGBAJQejLwdiz5neAr4XF1KvY7rKoMEYuBTMeCV%0A3dXJulL1r136W2zH4IRXp2lF%2FtYo6zKG%2B6KznsGErAYVzqOMSpFwqoAZ41JyAfPq%0Aaa9fwRDGcrszGceqy3PZgalePzItHNwWeO11PNU3x4X3idMpSz5wDT0YF0XCtXTW%0AMlBtDMs1AoGACdv8PaRfRwtEMA8V2%2BCsqOcrmDSkn5rCRz%2FxKoFqG6bN3KXsYA%2BS%0A%2FY2NRWBOPB4oDt%2FQQ5N68xwZSkprYMsaPENjmyZg9l%2BIsiqO2ifIPE5e49Yl3pjD%0A%2B0AvgWGq85foVKFk37M2evBtnZO2RfXbb6%2Fmmng7Rb2Y%2FAqSCR2A82A%3D%0A-----END%20RSA%20PRIVATE%20KEY-----%0A
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/importsshkey?api.version=&name=TestKey&user=username&key=-----BEGIN%20RSA%20PRIVATE%20KEY-----\r\n%0AMIIEpQIBAAKCAQEAqc%2FSzmxPfzQtXfLRfYP59M%2Bh33BHIH8tbRiM483hDLd6ZPs1%0ABGaDcZus5HMmddVjjfL5GqTd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Yw50PcUKUhBjwsA9R7Lt0Gu%2BKJU%2F8jx6dMFAoGBAL%2F76edIyF3DQrNY8jF0%0AD8VyGyvvXM1%2FZk1hKWtq0UBro2snKzI74YlAD0zrM8%2F%2BYqMygxli3%2BCoJpIOk9rP%0A3bMqbIZU%2BUJae5yTR0Fh2d0a9TUCb5VSnncf282rwvYDztZbkRwuCk21OCD3Whpo%0AL%2BkX2uK5Wv%2FuB%2FdE02uR52SBAoGBAJQejLwdiz5neAr4XF1KvY7rKoMEYuBTMeCV%0A3dXJulL1r136W2zH4IRXp2lF%2FtYo6zKG%2B6KznsGErAYVzqOMSpFwqoAZ41JyAfPq%0Aaa9fwRDGcrszGceqy3PZgalePzItHNwWeO11PNU3x4X3idMpSz5wDT0YF0XCtXTW%0AMlBtDMs1AoGACdv8PaRfRwtEMA8V2%2BCsqOcrmDSkn5rCRz%2FxKoFqG6bN3KXsYA%2BS\r\n%0A%2FY2NRWBOPB4oDt%2FQQ5N68xwZSkprYMsaPENjmyZg9l%2BIsiqO2ifIPE5e49Yl3pjD%0A%2B0AvgWGq85foVKFk37M2evBtnZO2RfXbb6%2Fmmng7Rb2Y%2FAqSCR2A82A%3D%0A\r\n-----END%20RSA%20PRIVATE%20KEY-----%0A
 Command Line
whmapi1 importsshkey name=TestKey user=username key=-----BEGIN%20RSA%20PRIVATE%20KEY-----\r\n%0AMIIEpQIBAAKCAQEAqc%2FSzmxPfzQtXfLRfYP59M%2Bh33BHIH8tbRiM483hDLd6ZPs1%0ABGaDcZus5HMmddVjjfL5GqTdmf2pElXaBXYrbFy8AU6fQfm254NLUgrWw0JTLfl0%0ACu4L0YfrTbuOmhKT1Fj2OxAMBlpahc%2BYvmThYbV%2FiofRLLWfOBDqwm2tIc0RwB47%0AlSVq8njy05sazQ1QEVSt6GD1d%2BlHOcj%2Ba9N96B1M9cC9N3oy%2BdHbDFC5Zj6nEuov%0AZstv5EWX49yZuimczpeqJXTmf4mp882TK0dq%2B6v%2BocVxAoqXMc94cTIy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oGBAJQejLwdiz5neAr4XF1KvY7rKoMEYuBTMeCV%0A3dXJulL1r136W2zH4IRXp2lF%2FtYo6zKG%2B6KznsGErAYVzqOMSpFwqoAZ41JyAfPq%0Aaa9fwRDGcrszGceqy3PZgalePzItHNwWeO11PNU3x4X3idMpSz5wDT0YF0XCtXTW%0AMlBtDMs1AoGACdv8PaRfRwtEMA8V2%2BCsqOcrmDSkn5rCRz%2FxKoFqG6bN3KXsYA%2BS\r\n%0A%2FY2NRWBOPB4oDt%2FQQ5N68xwZSkprYMsaPENjmyZg9l%2BIsiqO2ifIPE5e49Yl3pjD%0A%2B0AvgWGq85foVKFk37M2evBtnZO2RfXbb6%2Fmmng7Rb2Y%2FAqSCR2A82A%3D%0A\r\n-----END%20RSA%20PRIVATE%20KEY-----%0A

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

Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
userstring

Required

The key's owner

A valid filename.

username
name string

Required

The key's name.

A valid positive integer.TestKey

 

keystring

Required

The key's contents.

A valid key.
 Click to view...
-----BEGIN RSA PRIVATE KEY-----
%0AMIIEpQIBAAKCAQEAqc%2FSzmxPfzQtXfLRfYP59M%2Bh33BHIH8tbRiM483hDLd6ZPs1%0ABGaDcZus5HMmddVjjfL5GqTdmf2pElXaBXYrbFy8AU6fQfm254NLUgrWw0JTLfl0%0ACu4L0YfrTbuOmhKT1Fj2OxAMBlpahc%2BYvmThYbV%2FiofRLLWfOBDqwm2tIc0RwB47%0AlSVq8njy05sazQ1QEVSt6GD1d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Ok9rP%0A3bMqbIZU%2BUJae5yTR0Fh2d0a9TUCb5VSnncf282rwvYDztZbkRwuCk21OCD3Whpo%0AL%2BkX2uK5Wv%2FuB%2FdE02uR52SBAoGBAJQejLwdiz5neAr4XF1KvY7rKoMEYuBTMeCV%0A3dXJulL1r136W2zH4IRXp2lF%2FtYo6zKG%2B6KznsGErAYVzqOMSpFwqoAZ41JyAfPq%0Aaa9fwRDGcrszGceqy3PZgalePzItHNwWeO11PNU3x4X3idMpSz5wDT0YF0XCtXTW%0AMlBtDMs1AoGACdv8PaRfRwtEMA8V2%2BCsqOcrmDSkn5rCRz%2FxKoFqG6bN3KXsYA%2BS\r\n
%0A%2FY2NRWBOPB4oDt%2FQQ5N68xwZSkprYMsaPENjmyZg9l%2BIsiqO2ifIPE5e49Yl3pjD%0A%2B0AvgWGq85foVKFk37M2evBtnZO2RfXbb6%2Fmmng7Rb2Y%2FAqSCR2A82A%3D%0A\r\n
-----END RSA PRIVATE KEY-----
extract_publicBoolean

Whether to extract and save only the public key.

This parameter defaults to 1 for PPK (PuTTY Key Generator) files and 0 for all other imports.

  • 1 — Public key only.
  • 0 — All data.
0
extract_privateBoolean

Whether to extract and save only the private key.

This parameter defaults to 1 for PPK files and 0 for all other imports.

  • 1 — Private key only.
  • 0 — All data.
0
passphrasestring

The key's passphrase.

Note:

This parameter is required whenever you import a PPK file. 

This parameter defaults to a null value.

A valid and secure passphrase for a PPK file.12345luggage

Returns

ReturnTypeDescriptionPossible valuesExample
namestring

The key's name.

A valid string.

id_dsa