Use list ssh keys API to get list of sshkeys added in users through enduser panel.
HTTP Request
https://hostname:4085/index.php?act=managevps&vpsid=VPSID&add_ssh_keys=1
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | users | The action specified to carry out operation and return data | Yes |
add_ssh_keys | GET | Int | Pass this to add sshkeys | Yes |
vpsid | GET | Int | VPS in which to add ssh keys | Yes |
sshkeys | POST | Array | Array of sshkey id (sshkey id can be retirved using list ssh keys api) | Yes |
NOTE : SSH keys should be added in User through enduser.
Sample Code
<?php
require_once('/usr/local/virtualizor/sdk/admin.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'your_server_ip';
$admin = new Virtualizor_Admin_API($ip, $key, $pass);
$post['vpsid'] = 559;
$post['sshkeys'] = array(1,6); //ssh key ids which can be get using list ssh keys api
$output = $admin->add_sshkeys($post);
print_r(json_encode($output));
?>
Output
{
"done":{
"msg":"SSH keys were added sucessfully, SSH Keys will be applied when the VM is Powered off and started"
}
}