Authenticating fails on VPS/https

edynas

Registered
Apr 4, 2010
3
0
51
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($Curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($Curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($Curl, CURLOPT_REFERER, $reffer);
curl_setopt($Curl, CURLOPT_USERAGENT, $agent);  
curl_setopt($Curl, CURLOPT_URL, $cpanel_url);
curl_setopt($Curl, CURLOPT_USERPWD, $username.':'.$password);
curl_setopt($Curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($Curl,CURLOPT_SSL_VERIFYHOST,0);
$Output = curl_exec($Curl);
$end_url = curl_getinfo($Curl, CURLINFO_EFFECTIVE_URL);
I tried the sample code as well

PHP:
$curl = curl_init();		
# Create Curl Object
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);	
# Allow self-signed certs
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0); 	
# Allow certs that do not match the hostname
curl_setopt($curl, CURLOPT_HEADER,0);			
# Do not include header in output
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);	
# Return contents of transfer on curl_exec
$header[0] = "Authorization: Basic " . base64_encode($username.":".$password) . "\n\r";
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);  
# set the username and password
curl_setopt($curl, CURLOPT_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
 

raonaveed

Member
Nov 30, 2009
13
0
51
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?
 

edynas

Registered
Apr 4, 2010
3
0
51
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?
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.
 

leefrom

Active Member
May 27, 2008
30
0
56
@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?
 

edynas

Registered
Apr 4, 2010
3
0
51
@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?
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