- Created by Documentation, last modified on Apr 09, 2018
disable_authentication_provider
disable_failing_authentication_providers
enable_authentication_provider
get_available_authentication_providers
get_provider_client_configurations
get_provider_configuration_fields
get_provider_display_configurations
get_users_authn_linked_accounts
set_provider_client_configurations
set_provider_display_configurations
twofactorauth_generate_tfa_config
twofactorauth_get_user_configs
cpgreylist_is_server_netblock_trusted
cpgreylist_list_entries_for_common_mail_provider
cpgreylist_load_common_mail_providers_config
cpgreylist_save_common_mail_providers_config
cpgreylist_trust_entries_for_common_mail_provider
cpgreylist_untrust_entries_for_common_mail_provider
create_cpgreylist_trusted_host
delete_cpgreylist_trusted_host
Description
This function authorizes a key to access the server via SSH.
Warning:
- Do not transfer private keys over insecure ports.
- Only the
root
account can use this function, and it only affects theroot
keys. To perform this function on a regular user account, call the cPanel API 2 SSH::authkey function through the WHM API.
Examples
https://hostname.example.com:2087/cpsess##########/json-api/authorizesshkey?api.version=1&user=username&file=%2Fhome%2Fusername%2Fsshkey&authorize=1
https://hostname.example.com:2087/cpsess##########/xml-api/authorizesshkey?api.version=1&user=username&file=%2Fhome%2Fusername%2Fsshkey&authorize=1
whmapi1 authorizesshkey user=username file=%2Fhome%2Fusername%2Fsshkey authorize=1
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. If you run CloudLinux™, you must use the full path of the
whmapi1
command:/usr/local/cpanel/bin/whmapi1
{ "metadata": { "reason": "OK", "version": 1, "command": "authorizesshkey", "result": 1 }, "data": { "file": "test", "authorized": 1 } }
<result> <metadata> <result>1</result> <version>1</version> <reason>OK</reason> <command>authorizesshkey</command> </metadata> <data> <file>test</file> <authorized>1</authorized> </data> </result>
Note:
Parameters
Note:
You must include either the file
or the text
parameter.
Parameter | Type | Description | Possible values | Example |
---|---|---|---|---|
file | string | The SSH key file's name. | An absolute file path. |
sshkey
|
text | string | The text of the SSH public key file. | A valid SSH key. | Click to view... ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB3NzaC1yc2EAAAABIwAAAQEA4fTwKg8fA4Ey5/fwyZdeiWoktiXwx1dAAAAAA AAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB3NzaC1yc2EAAAABIwAAAQEA4fTwKg8fA4Ey5/fwyZdeiWoktiXwx1dAAAAAA AAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB3NzaC1yc2EAAAABIwAAAQEA4fTwKg8fA4Ey5/fwyZdeiWoktiXwx1dAAAAAA AAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB3NzaC1yc2EAAAABIwAAAQEA4fTwKg8fA4Ey5/fwyZdeiWoktiXwx1dAAAAAA AAAAAAAAAAAA == REPO user@example.com |
user | string | The SSH key's username. | A valid username. | username |
authorize | Boolean | Whether to authorize the SSH key to access the server. |
| |
options | string | Options to include with the SSH key. | A valid string. | null
|
Returns
Return | Type | Description | Possible values | Example |
---|---|---|---|---|
file | string | The SSH key file's name. | A valid filename. | TestKey |
| Boolean | Whether the SSH key is authorized to access the server. |
|
|
Function information
API Version:
Available in:
WHM 11+
Methods:
GET, POST
Required Parameters:
Return Formats:
About WHM API 1
WHM API 1 performs functions and accesses data in WHM.
Notes:
- Some functions and parameters may require that you authenticate as the
root
user. - You must use the appropriate WHM ports (
2086
or2087
) to call WHM API functions.
Find a function
Related functions
-
Page:WHM API 1 Functions - accesshash — This function regenerates or retrieves a user's access hash.
-
Page:WHM API 1 Functions - listcrts — This function lists the server's domains with installed SSL certificates.
-
Page:WHM API 1 Functions - deletesshkey — This function function deletes an SSH key from the server.
-
Page:WHM API 1 Functions - authorizesshkey — This function authorizes a key to access the server via SSH.
-
Page:WHM API 1 Functions - check_remote_ssh_connection — This function tests an SSH connection to another server.