Add SSH Key


This article provides a guide for a VPS Reseller user to add SSH key via API.

Use Add SSH key API to add an SSH key to your VPS.

HTTP Request

https://vm1.apivps.com:4083/index.php?act=addsshkey

Parameters

Name Type Value Description Required
act GET addsshkey The action which will return data belonging to a particular page Yes
name POST text Provide name of SSH key.. Yes
value POST text Provide your public SSH key you want to add 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);
	
	$post['name'] = 'testkey';//name of key
	$post['value'] = 'ssh-rsa AAAAB3Nza...Klj7w==root@example.com'//public ssh key
	$vps = $v->addsshkey($post);
	
    print_r(json_encode($vps));
?>

Curl

curl -k -X POST -d "add=1&name=test" --data-urlencode value='ssh-rsa AAAAB3Nza...Klj7w== root@example.com' -L "https://vm1.apivps.com:4083/index.php?act=addsshkey&api=json&apikey=your_api_key&apipass=your_api_pass"

Output

{
   "uid":"600",
   "act":"addsshkey",
   "timezone":2,
   "timenow":"June 6, 2023, 1:36 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:\/\/radwebhosting.com",
   "enable_eu_iso":1,
   "billing_symbol":"$",
   "enable_registration":0,
   "inhouse_billing":"0",
   "title":"KVMTestServer",
   "done":{
      "msg":"The SSH key has been added successfully",
      "goto":"act=sshkeys"
   },
   "keyid":"2",
   "time_taken":"0.095"
}

Conclusion

You now know how to add SSH key as a VPS Reseller for use with VPS servers.

  • vps api, api, ssh keys, ssh
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Cloud Resources

This article provides a guide for a VPS Reseller user to get cloud resources available to the...

Delete VM

This article provides a guide for a VPS Reseller user to delete VM via API. Use Delete VM API to...

Create VM

This article provides a guide for a VPS Reseller user to create VM via API. Use Create VM API to...

Add ISO

This article provides a guide for a VPS Reseller user to add a new ISO to a VPS via API. Use Add...

List SSH Keys

This article provides a guide for a VPS Reseller user to list SSH keys via API. Use List SSH...