Edit SSH key

Use Edit SSH key API to edit existing ssh key on VPS of your server.

HTTP Request

https://hostname:4083/index.php?act=editsshkey&keyid=SSHKEYID

Parameters

NameTypeValueDescriptionRequired
actGETeditsshkeyThe action which will return data belonging to a particular pageYes
keyidPOSTintProvide SSH key id of which you want to edit the information.Yes
namePOSTtextProvide new SSH key name.Yes
valuePOSTtextProvide new SSH public key.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);
	
	$keyid = 3;//id
	$post['name'] = 'test1';//name of key
	$post['value'] = 'ssh-rsa AAAAB3Nza...Klj7w== root@example.com';//public sah key
	$vps = $v->editsshkey($post);
	
    print_r(json_encode($vps));
?>

Curl

curl -k -X POST -d "edit=1&keyid=3&name=test1" --data-urlencode value='ssh-rsa AAAAB3Nza...Klj7w== root@example.com' -L "https://hostname:4083/index.php?act=editsshkey&api=json&apikey=your_api_key&apipass=your_api_pass"

Output

{
   "uid":"600",
   "act":"editsshkey",
   "timezone":2,
   "timenow":"July 25, 2019, 6:57 am",
   "vpsid":"6710",
   "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 has been saved successfully",
      "goto":"act=sshkeys"
   },
   "ssh_key":{
      "keyid":"3",
      "name":"test1",
      "value":"ssh-rsa AAAAB3Nza...Klj7w== root@example.com"
   },
   "time_taken":"0.101"
}
Was this helpful to you?