SSH Keys and Connections
Enable SSH key for server
This function authorizes a public SSH key to access the server. When you call this function, it adds the key to the /root/.ssh/authorized_keys file.
Warning:
- Do not transfer private keys over insecure ports.
- Only root and root-enabled resellers can use this function, and it only affects the root public SSH keys. To perform this function on a regular user account, call the cPanel API 2 SSH::authkey function via the WHM API. For more information, read our Use WHM API to Call cPanel API and UAPI documentation.
get/authorizesshkey
Query parameters
authorize1 | 0 required
Example:1
Whether to authorize the public SSH key to access the server.
- 1 — Authorize.
- 0 — Do not authorize.
filestring required
Example:sshkey.pub
The public SSH key file's name.
Note:
- This file must exist in the /root/.ssh directory.
- If you call both the file and the text parameters, the function ignores the file parameter.
textstring required
Example:ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCys7JbGhkAZ8E4Pmq8D4EBm1UedKK2oMhs3RVIEFRJX6S86Itw6Qmhds62LNGrxuVL11W6v25+maIiBhXnslyQpd838tHyAC7J/SJojDid8acovX/4xgJQaJHLAh9tLgyQXnNhIxIGJ4nVZ+8OqM2Vb1Cps+E5H17ivG07PXnVPEvwMaeWkm2DnGgSy5kmjVpNKlj9GWFCn/SJd7up7QnbGKoz87pxKDs3esp+ziuPEAJHLeXnKHWPVukQgtRUpUBdqkCvu5hUkhpaiWmBR8yxajkxbSObPw+ZkELhmm+fQseOfEbrwToMRJCO7gAKwBtNi7OhyFM7YFrvdo0xh6cn
The text of the SSH public key file.
Note:
- If you call both the file and the text parameters, the function ignores the file parameter.
optionsstring
Example:agent-forwarding,cert-authority
A comma-separated list of options to include with the public SSH key. For a list of options, read the OpenBSD manaual.
This parameter defaults to no options.
Response
HTTP Request was successful.
Example response
{
"data": {
"authorized": 1,
"file": "sshkey.pub"
},
"metadata": {
"command": "authorizesshkey",
"reason": "OK",
"result": 1,
"version": 1
}
}