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:
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.authorize required | integer Whether to authorize the public SSH key to access the server.
Example: authorize=1 |
file required | string The public SSH key file's name. Note:
Example: file=sshkey.pub |
text required | string The text of the SSH public key file. Note:
Example: text=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCys7JbGhkAZ8E4Pmq8D4EBm1UedKK2oMhs3RVIEFRJX6S86Itw6Qmhds62LNGrxuVL11W6v25+maIiBhXnslyQpd838tHyAC7J/SJojDid8acovX/4xgJQaJHLAh9tLgyQXnNhIxIGJ4nVZ+8OqM2Vb1Cps+E5H17ivG07PXnVPEvwMaeWkm2DnGgSy5kmjVpNKlj9GWFCn/SJd7up7QnbGKoz87pxKDs3esp+ziuPEAJHLeXnKHWPVukQgtRUpUBdqkCvu5hUkhpaiWmBR8yxajkxbSObPw+ZkELhmm+fQseOfEbrwToMRJCO7gAKwBtNi7OhyFM7YFrvdo0xh6cn |
options | string 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. Example: options=agent-forwarding,cert-authority |
HTTP Request was successful.
object | |
object |
whmapi1 --output=jsonpretty \ authorizesshkey \ file='sshkey.pub' \ text='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCys7JbGhkAZ8E4Pmq8D4EBm1UedKK2oMhs3RVIEFRJX6S86Itw6Qmhds62LNGrxuVL11W6v25+maIiBhXnslyQpd838tHyAC7J/SJojDid8acovX/4xgJQaJHLAh9tLgyQXnNhIxIGJ4nVZ+8OqM2Vb1Cps+E5H17ivG07PXnVPEvwMaeWkm2DnGgSy5kmjVpNKlj9GWFCn/SJd7up7QnbGKoz87pxKDs3esp+ziuPEAJHLeXnKHWPVukQgtRUpUBdqkCvu5hUkhpaiWmBR8yxajkxbSObPw+ZkELhmm+fQseOfEbrwToMRJCO7gAKwBtNi7OhyFM7YFrvdo0xh6cn' \ authorize='1'
{- "data": {
- "authorized": 1,
- "file": "sshkey.pub"
}, - "metadata": {
- "command": "authorizesshkey",
- "reason": "OK",
- "result": 1,
- "version": 1
}
}