Get Virtualizor

Add SSH Keys

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

NameMethodValueDescriptionRequired
actGETusersThe action specified to carry out operation and return dataYes
add_ssh_keysGETIntPass this to add sshkeysYes
vpsidGETIntVPS in which to add ssh keysYes
sshkeysPOSTArrayArray 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"
   }
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list