Skip to main content

Login WHM via Remote Access Key

Comments

1 comment

  • cPanelMichael
    Hello, Here's an example of how to authenticate as root to WHM using the access hash in a PHP script:
    $whmusername = "root"; # The contents of /root/.accesshash $hash = "accesshashhere"; $query = "https://127.0.0.1:2087/json-api/listaccts?api.version=1"; $curl = curl_init(); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($curl, CURLOPT_RETURNTRANSFER,1); $header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'","",$hash); curl_setopt($curl,CURLOPT_HTTPHEADER,$header); curl_setopt($curl, CURLOPT_URL, $query); $result = curl_exec($curl); if ($result == false) { error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query"); } curl_close($curl); print $result; ?>
    This is fully documented at: Guide to API Authentication - Access Hash Authentication - Software Development Kit - cPanel Documentation Could you review this document and let us know if you have any specific questions? Thanks!
    0

Please sign in to leave a comment.