Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Authorization: Basic works but Authorization: WHM doesn't.

Discussion in 'cPanel Developers' started by netshine, Jun 28, 2011.

  1. netshine

    netshine Member

    Joined:
    Dec 5, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    151
    SOLVED: Authorization: Basic works but Authorization: WHM doesn't.

    I am writing an automation script for cPanel, and it works fine if I use basic authorization. If I try to use a remote access key though, I get a 403 Forbidden HTTP header returned, with 'Access Denied' in the cpanelresult element. Here is my code (PHP):

    Code:
    if (strlen($server->whm_remote_access_key) > 0)
    {
        $header[0] = "Authorization: WHM " . $server->whm_username . ":" . preg_replace("'(\r|\n)'","", $server->whm_remote_access_key);
    }
    else
    {
        $header[0] = "Authorization: Basic " . base64_encode($server->whm_username.":".$server->whm_password);
    }
    If a password is supplied, but no remote access key, it works fine. If the remote access key is supplied, it fails with access denied. I have double checked that the hash is correct, and tried re-generating the hash in WHM, but it always fails. Is there something else I need to do in WHM to get it to allow remote access keys to work? Thanks.
     
    #1 netshine, Jun 28, 2011
    Last edited: Jun 29, 2011
  2. netshine

    netshine Member

    Joined:
    Dec 5, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    151
    I figured it out. The remote access key is unique to the user you try to login with. I was trying to login using the root remote access key but with a reseller username, as I assumed the remote access key was the same for all users.
     
  3. cPanelDavidN

    cPanelDavidN Integration Developer

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    3
    Trophy Points:
    68
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi netshine,

    You conclusion is correct. The remote access is only for the 'root' user.

    As a side not to all: It's important that this access hash remain secure and private since it will give full, remote API access to root actions on your server.

    Regards,
    -DavidN
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice