The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Authenticating fails on VPS/https

Discussion in 'cPanel Developers' started by edynas, Apr 25, 2010.

  1. edynas

    edynas Registered

    Joined:
    Apr 4, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Not sure why but I just can't get access on a cpanel account that is located on a vps.

    This works on my other servers
    PHP:
    $Curl curl_init();
    curl_setopt($CurlCURLOPT_RETURNTRANSFERtrue);
    curl_setopt($CurlCURLOPT_FOLLOWLOCATIONtrue);
    curl_setopt($CurlCURLOPT_REFERER$reffer);
    curl_setopt($CurlCURLOPT_USERAGENT$agent);  
    curl_setopt($CurlCURLOPT_URL$cpanel_url);
    curl_setopt($CurlCURLOPT_USERPWD$username.':'.$password);
    curl_setopt($CurlCURLOPT_SSL_VERIFYPEER0);
    curl_setopt($Curl,CURLOPT_SSL_VERIFYHOST,0);
    $Output curl_exec($Curl);
    $end_url curl_getinfo($CurlCURLINFO_EFFECTIVE_URL);
    I tried the sample code as well

    PHP:
    $curl curl_init();        
    # Create Curl Object
    curl_setopt($curlCURLOPT_SSL_VERIFYPEER,0);    
    # Allow self-signed certs
    curl_setopt($curlCURLOPT_SSL_VERIFYHOST,0);     
    # Allow certs that do not match the hostname
    curl_setopt($curlCURLOPT_HEADER,0);            
    # Do not include header in output
    curl_setopt($curlCURLOPT_RETURNTRANSFER,1);    
    # Return contents of transfer on curl_exec
    $header[0] = "Authorization: Basic " base64_encode($username.":".$password) . "\n\r";
    curl_setopt($curlCURLOPT_HTTPHEADER$header);  
    # set the username and password
    curl_setopt($curlCURLOPT_URL$end_url);            
    # execute the query
    $result curl_exec($curl);
    if (
    $result == false) {
        
    error_log("curl_exec threw error \"" curl_error($curl) . "\" for $query");    
    # log error if curl exec fails
    }
    curl_close($curl);
    But both give me an error 7 "Can't connect to host"

    My only guess left now is that it might be a firewall setting. If so is it something I can bypass or do i need to ask the hosting company to turn of the blocking?

    Edwin
     
  2. raonaveed

    raonaveed Member

    Joined:
    Nov 30, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    What will be code of non-remote script means if i want to create a plugin and using that if i want to access list accounts or create account than how i am gona do all these codes are for remote integration not for local and why i provide username and password for such plugin to work when i already have files in side the server it should auto seems root working isn't?
     
  3. edynas

    edynas Registered

    Joined:
    Apr 4, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Not sure why you post it here but creating accounts can only be done when you are logged in. Listing accounts can be done if you have access to server by for instance ftp but it's easier to have it thru the cpanel api.
     
  4. leefrom

    leefrom Active Member

    Joined:
    May 27, 2008
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    6
    @edynas: If it works on one server, it should work on a vps as well. I doubt the fact that it's a vps is the issue.

    Obviously my first guess would be that the password is incorrect. Have you tried resetting it?

    Do you get anything in /usr/local/cpanel/logs/error_log or access_log, or login_log when it fails?
     
  5. edynas

    edynas Registered

    Joined:
    Apr 4, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Thanks lee

    Password is ok as when I go to cpanel in a browser and i use that password/username I am able to login.
    The error I am getting in Curl is 7 which says "can't connect to host" Looking in Google the most issues I see has to do with a firewall blocking the cpanel port for use remotly.

    Edwin
     
Loading...

Share This Page