Generate Keys

Use the generate ssh keys API to generate new pair of keys.

HTTP Request

https://hostname:4085/index.php?act=addvs&generate_keys=1

Parameters

NameMethodValueDescriptionRequired
actGETaddvsThe action specified to retrieve dataYes

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);

    $output = $admin->generate_keys();

    print_r(json_encode($output));

?>

Output

{
"public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD5zfj4jGDwtx5m.. root@lxc",
"private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEA+c34+Ixg8LceZs7bQUvUvS7m7GyRvz09a9A00gIwqaBdG0Hz\nEOo+6sdxAVdI8c3+LfhSQieQrxPmMjon0Obky/sF3YOwI+y09m6f6ZWcP+/raRnN\nb2I61EcfQJyoViYkzML3p6XAhP12qFJemATwqjtYAyygdZCzHtHJILZvyAQejeRd\nEj8ac1s8rVAw1B5TmxPMojyXgYsi0t9D8mIRCWuRHbxky0tcp6jA0U6HOyeB6SQp...\n-----END RSA PRIVATE KEY-----",
"path": "/var/virtualizor/ssh-keys/"
}
Was this page helpful?