Use Apply SSH key API to apply existing SSH key to VPS of your server.
HTTP Request
https://hostname:4083/index.php?act=sshkeys&svs=VID
Parameters
Name | Type | Value | Description | Required |
---|---|---|---|---|
act | GET | sshkeys | The action which will return data belonging to a particular page. | Yes |
svs | POST | int | Provide VPS ID on which you want to apply SSH key. | Yes |
ssh_keys | POST | array | Provide an array of SSH keys you want to apply. | Yes |
Sample Code
PHP
<?php
require_once('/usr/local/virtualizor/sdk/enduser.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'host_ip';
$v = new Virtualizor_Enduser_API($ip, $key, $pass);
$vid = 6709;//vps id
$post['ssh_keys'] = array('5');//id
$vps = $v->applysshkeys($vid,$post);
print_r(json_encode($vps));
?>
Curl
curl -k -X POST -d "ssh_keys[]=5&addkeyvps=1" -L "https://kvm.nuftp.com:4083/index.php?act=sshkeys&svs=6709&api=json&apikey=your_api_key&apipass=your_api_pass"
Output
{
"uid":"600",
"act":"sshkeys",
"timezone":2,
"timenow":"July 25, 2019, 7:43 am",
"vpsid":6709,
"username":"a@a.com",
"user_type":"2",
"preferences":{
"theme":"default",
"language":"english",
"timezone":2
},
"url":"index.php?",
"rdns":{
"pdnsid":null
},
"support_link":"http:\/\/softaculous.com",
"enable_eu_iso":1,
"billing_symbol":"$",
"enable_registration":0,
"inhouse_billing":"0",
"title":"KVMTestServer",
"done":{
"msg":"The SSH key(s) have been added successfully. The changes will take effect on next reboot."
},
"ssh_keys":[
5
],
"time_taken":"0.836"
}