Monday, December 29, 2014

"xmlrpc error: Expected to have 1 children, found 0"

APPLIES TO:
  • Parallels Plesk 11.0 for Linux
  • Parallels Plesk 11.5 for Linux
  • Parallels Plesk 11.0 for Windows
  • Parallels Plesk 11.5 for Windows
  • Parallels Plesk 10.4 for Windows
  • Parallels Plesk 10.3 for Windows

Symptoms

Parallels Plesk shows the following error:
xmlrpc error: Expected <param> to have 1 children, found 0
---------------------- Debug Info -------------------------------
0: common_func.php3:4675
        of_get_all_keys()
1: common_func.php3:4675
        pkey_fetch_key_list()
2: KeyInfoForm.php:171
        KeyInfoForm->get_bye_online_url(string 'new', string '')
3: KeyInfoForm.php:77
        KeyInfoForm->assign()
4: key_info.php:43
        require(string 'C:\Program Files\Parallels\Plesk\admin\htdocs\server\key_info.php')
5: plesk.php:66

Cause

The file %plesk_dir%\admin\repository\registry.xml is empty.

Resolution

  1. Remove the file %plesk_dir%\admin\repository\registry.xml.
  2. Click the OK button on the error screen or log into the Plesk Control Panel again.
  3. Click the Retrieve Keys button on the License Management screen to re-apply the license.

Sunday, December 28, 2014

Unable to remove an IP address "Error: The IP address is already used for hosting"

APPLIES TO:
Parallels Plesk 11.5 for Linux
Parallels Plesk 11.5 for Windows

Symptoms
An attempt to delete an IP address from Parallels Plesk Panel failwith the following error:
Error: The IP address `<ip_address>` is already used for hosting. 
However, in Tools & Settings > IP Addresses, no sites are shown to use this IP address.

Cause
This is caused by a Plesk database inconsistency. The psa.IpAddressesCollections table
was not correctly updated when IP addresses were changed for domains.
Resolution
Create a psa database backup.

Windows:
"%plesk_dir%\MySQL\bin\mysqldump.exe" -uadmin -P8306 -p<PleskPasswordHere> psa > c:\psadump.sql
Linux: 
   mysqldump -uadmin -pcat /etc/psa/.psa.shadow psa > /tmp/psa.date +%F_%H.%M.sql

Find out which id is assigned to the IP address in question, and find any (sub)domains that have this IP address assiged:

mysql> select @ip_id := id from IP_Addresses where ip_address='10.10.10.10';
mysql> SELECT d.name, d.webspace_id, ipac.ipCollectionId,ip.ip_address FROM DomainServices ds INNER JOIN IpAddressesCollections ipac ON ds.ipCollectionId = ipac.ipCollectionId INNER JOIN domains d ON d.id = ds.dom_id  JOIN IP_Addresses ip on ipac.ipaddressid=ip.id WHERE (ds.type = 'web' OR ds.type = 'mail') and ipac.ipAddressId = @ip_id;

Make sure the 10.10.10.10 IP address is replaced with the one to be deleted. 

Find records in the IpAddressesCollections table that correspond to the IP address in question:

mysql> select * from IpAddressesCollections where ipaddressid=@ip_id;

Find out which id is assigned to the IP address that
 should be used for the (sub)domains from the previous output, then 
update the corresponding records of the IpAddressesCollections table:

For example, the 10.10.10.11 IP address should be assigned to example.com:

mysql> set @domain_name := 'example.com';
mysql> select @ip_id_new := id from IP_Addresses where ip_address='10.10.10.11';
mysql> update IpAddressesCollections ipac  INNER JOIN DomainServices ds ON ds.ipCollectionId = ipac.ipCollectionId INNER JOIN domains d ON d.id = ds.dom_id  JOIN IP_Addresses ip on ipac.ipaddressid=ip.id set ipac.ipAddressId=@ip_id_new WHERE (ds.type = 'web' OR ds.type = 'mail') and ipac.ipAddressId = @ip_id and d.name=@domain_name;

Ref:http://kb.sp.parallels.com/en/122207


Thursday, December 25, 2014

Domain Name Lifecycle

This is a life-cycle of a typical domain name, from registration to deletion.









Monday, December 22, 2014

Resizing VHDX in Windows 2012 using PowerShell

In order to be able to resize the VHD you need to follow few steps first. You can do that from the GUI, however in my experience your best rate of success is to use the PowerShell. Please note that this apply only to Hyper-V in Windows 2012 and above, there isn’t a process available yet for the previous versions of Hyper-V

Below are the steps of how to do that, just as an explanation in order to be able to resize the VHD we need to resize the partition inside the Virtual machine, as to let the vhd file know that this space is free and its safe to remove it.

The command below will provide all the steps required to resize the vhd, however it requires the server to be shut down. The steps are as follow:

1. Shut down the VM
2. Mount the VHD using mount-vhd command with command line as follow:

mount-vhd path\drive.vhdx -passthru | get-disk | get-partition | get-volume

This command will provide you with information of what drive letter the partitions inside vhdx files have been assigned as well as the size details (remember that from Windows 2008 and up the system create a 100-300MB partition on the main drive used in booting process, don’t resize it)

3. The next command is resize-partition, that is to resize the size of the partition inside the vhdx to the size you want it to be

resize-partition –driveletter D -size 40GB

-driveletter is the drive letter we get from the first command, and –size is the size to what we want to shrink the partition to.

4. Next we will dismount the vhd using dismount-vhd:

dismount-vhd path\drive.vhdx

5. The last command is actual resizing of the VHD, to do that we use: resize-vhd command:

resize-vhd path\drive.vhdx -ToMinimumSize

Sunday, December 21, 2014

Remove Server and PHP info from response header

Below is a common HTTP Response Header:

HTTP/1.1 200 OK
Date: Wed, 21 Dec 2014 01:18:27 GMT
Server: Apache/2.0.55 (Debian) PHP/5.1.2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store,no-cache,must-revalidate,post-check=0,pre-check=0
Pragma: no-cache
Content-Encoding: gzip
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
To keep your server safe from attack, you should hide all unnecessary info about your system.With apache,this was control by ServerTokens nd Server Signature config directive. From apache manual,we will find out all config value of ServerTokens and its sample out.

ServerTokens Prod[uctOnly]
Server sends (e.g.): Server: Apache
ServerTokens Major
Server sends (e.g.): Server: Apache/2
ServerTokens Minor
Server sends (e.g.): Server: Apache/2.0
ServerTokens Min[imal]
Server sends (e.g.): Server: Apache/2.0.41
ServerTokens OS
Server sends (e.g.): Server: Apache/2.0.41 (Unix)
ServerTokens Full (or not specified)
Server sends (e.g.): Server: Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.2

Obviously, we should turn our config to ServerTokens Prod.To stop apache
from exposing info in related error page,need to turn off ServerSignature.
ServerSignature off

To hide the php related information,locate php config file, add:
expose_php off

Kill restore process in new cpanel

Kill restore process in new cpanel

In new cpanel/WHM when we try to kill restore process it is still showing in WHM >> restore full backup. Below are the steps to remove that process from WHM.
You can manually mark the transfer as completed using the following instructions:
Ensure the transfer is no longer running by clicking on the “View” option under “Sessions in Progress” for this transfer. In the new window, there will be a line that looks like this:
You may close this window and view the transfer on the command line: /usr/local/cpanel/bin/view_transfer 1071601843quick20141013154952IAZhRro
Access your server via SSH and run that command (the transfer name will be different on your server):
/usr/local/cpanel/bin/view_transfer 1071601843quick20141013154952IAZhRro
As an example, you might see output like this:
Transfer running with pid: paused
[795 ][MASTER ]: Start Session
[795 ][MASTER ]: Version: 1.9
You will note that the master PID for this transfer is xxx. If the process still exists, and the transfer has failed, then you can kill that process:
kill -9 xxx
The next step requires you to change the entry for this transfer in the whmxfer.sessions table in MySQL. Find the entry with the session ID for your migration. In the example we have been using, it’s ‘ 1071601843quick20141013154952IAZhRro .’ It will look like this:
mysql -e “select * from whmxfer.sessions where sessionid=’1071601843quick20141013152137YIVT7Ze'”
+————————————–+————–+——-+———+———————–+————-+——-+———————+———+
| sessionid | initiator | pid | version | target_host | source_host | state | starttime | endtime |
+————————————–+————–+——-+———+———————–+————-+——-+———————+———+
| 1071601843quick20141013152137YIVT7Ze | quickrestore | 21295 | 1.9 | vps.techfix.com | localhost | 50 | 2014-11-15 09:11:17 | NULL |
+————————————–+————–+——-+———+———————–+————-+——-+———————+———+
You will need to change the ‘state’ field to 100, and change the ‘endtime’ field from NULL to a time after the ‘starttime’ field:
mysql -e “update whmxfer.sessions set state=’100′, endtime=’2014-10-14 09:37:52′ where sessionid=’1071601843quick20141013152137YIVT7Ze'”
If you check it again then you will notice that process ended.
+————————————–+————–+——-+———+———————–+————-+——-+———————+———————+
| sessionid | initiator | pid | version | target_host | source_host | state | starttime | endtime |
+————————————–+————–+——-+———+———————–+————-+——-+———————+———————+
| 1071601843quick20141013152137YIVT7Ze | quickrestore | 21295 | 1.9 | vps.techfix.com | localhost | 100 | 2014-10-13 08:21:37 | 2014-10-14 09:37:52 |
+————————————–+————–+——-+———+———————–+————-+——-+———————+———————+
The transfer should then no longer appear under “Sessions in Progress.”

You can reconfirm the same by login into WHM.

Friday, December 19, 2014

Errors when trying to open Parallels Plesk

APPLIES TO:
  • Parallels Plesk 11.0 for Linux
  • Parallels Plesk 11.5 for Linux
  • Parallels Plesk 11.0 for Windows
  • Parallels Plesk 11.5 for Windows
  • Parallels Plesk 10.4 for Windows

Symptoms

It is not possible to access Parallels Plesk. The browser displays one of the following errors:
ERROR: SWKeyExFatalError
xmlrpc error: XML parsing failed
Along with the following stack trace:
0: common_func.php3:4523
of_get_key_by_product(string 'plesk-win')
1: common_func.php3:4523
getPleskKey()
2: common_func.php3:4602
getKeyProp(string 'demo')
3: auth.php3:54
Alternatively, you may see an error like this:
    xmlrpc error: Expected <param> to have 1 children, found 0
    ---------------------- Debug Info -------------------------------
    0: common_func.php3:4684
         of_get_all_keys()
    1: common_func.php3:4684
         pkey_fetch_key_list()
    2: KeyInfoForm.php:171
         KeyInfoForm->get_bye_online_url(string 'new', string '')
    3: KeyInfoForm.php:77
         KeyInfoForm->assign()
    4: key_info.php:4 

Cause

The above error indicates that either the %plesk_dir%\admin\repository\registry.xml file and/or one of the license key files from %plesk_dir%\admin\repository\keys\ is corrupt.

Resolution

Delete or rename the '%plesk_dir%\admin\repository\registry.xml' file and try to access Plesk again. A new file should have been generated automatically. Alternatively, rename the corrupted file and execute the command below:
    C:\Parallels\Plesk\admin\bin>keymng.exe --get-key-number
If this does not resolve the issue, one or several license key files from '%plesk_dir%\admin\repository\keys\' could be corrupt. You can use the following algorithm to resolve the issue:
  1. Check the contents of the '%plesk_dir%\admin\repository\keys\' folder. If it contains only one license key file, this is probably the main Plesk license. If it is corrupt (improper XML syntax or the file is just empty), please obtain the valid license file from your provider and install using the following command:
    "%plesk_bin%\keymng.exe" --install --source-file=<path_to_file>
    
    Now Plesk should be working.
  2. If there are several license files, you need to find out which of them is the main Plesk license file. It will contain patterns similar to the below:
    <core:description>
    <core:keytype>Parallels Plesk Panel 10.x/11.x and Later for Windows </core:keytype>
    <core:product core:type="string">plesk-win</core:product>
    
    Only leave the main Plesk license file in '%plesk_dir%\admin\repository\keys\' and make sure you can log into Plesk. If not, proceed with item one.
  3. Log into Plesk and click 'receive keys' in the "Tools % Settings > License" section. This will automatically fetch all additional keys from KA unless there are connection problems with the KA server.

Reset CPHulk data to regain access

Login to your server via SSH as the root user.

Run the following command to see login attempts that have happened:

    mysql -e "select * from cphulkd.logins;"
    In this case we can see that we had some login attempts to an email account user@example.com from the IP address 123.123.123.123:

    +------------------+---------------+---------+--------+---------------------+
    | USER | IP | SERVICE | STATUS | LOGINTIME |
    +------------------+---------------+---------+--------+---------------------+
    | user@example.com | 123.123.123.123 | mail | 0 | 2013-02-27 13:04:25 |
    | user@example.com | 123.123.123.123 | mail | 0 | 2013-02-27 13:04:29 |
    | user@example.com | 123.123.123.123 | mail | 0 | 2013-02-27 13:04:39 |
    +------------------+---------------+---------+--------+---------------------+

    Next run the following command to find detected bruce force attempts:

   mysql -e "select * from cphulkd.brutes;"

    Here we can see that those email account login attempts cause a brute force block on the IP:

    +---------------+--------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+
    | IP | NOTES | BRUTETIME | EXPTIME |
    +---------------+--------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+
    | 123.123.123.123 | 5 failed login attempts to account user@example.com (mail) -- Large number of attempts from this IP: 123.123.123.123 | 2013-02-27 13:04:54 | 2013-02-27 13:09:54 |
    +---------------+--------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+

    If you wanted to, you could simply wait until the EXPTIME which is the expiration time that the block will expire, and then you'll be able to login again.

    If you wanted to go ahead and clear out the block, and regain access right away, then you can run the following commands to re-allow access for the 123.123.123.123 IP address:

    mysql -e "delete from cphulkd.logins where IP='123.123.123.123';"
    mysql -e "delete from cphulkd.brutes where IP='123.123.123.123';"

Monday, December 1, 2014

10 WHM Command Line Tips and Tricks

Create an account:
/scripts/createacct <options>
Changing a Site’s IP Address
/usr/local/cpanel/bin/setsiteip [-u user | domain] ip
Remove, suspend, or unsuspend an account:
/scripts/killacct $user
/scripts/suspendacct $user “$reason”
/scripts/unsuspendacct $user
Change an account’s password:
/scripts/realchpass $user 'password'
Find out who owns a domain name:
/scripts/whoowns $user
grep $domain /etc/userdomains
View IP address usage:
/scripts/ipusage
cat /etc/domainips
Install an SPF Record or DomainKey:
/usr/local/cpanel/bin/spf_installer $user
/usr/local/cpanel/bin/domain_keys_installer $user
Run statistics:
/scripts/runweblogs $user (one user)
/scripts/runlogsnow (all users)
Change a MySQL password:
/scripts/mysqlpasswd $user '$password'
View user resource usage (WHM > Daily Process Log):
/usr/local/cpanel/bin/dcpumonview
As you may notice, most of the commonly-used commands are in two locations: /scripts and /usr/local/cpanel/bin . Take a look at the scripts in those folders and find which ones may be useful for your day-to-day tasks.

You can also check out cPanel’s listing of scripts, located at http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/WHMScripts .
Remember though – never run a script that you’re not familiar with, especially as root. Doing so could yield unexpected results or damage your system.

Thursday, November 20, 2014

Installing and configuring MailEnable

Guide to installing and configuring MailEnable. Includes pre and post installation requirements.

Configuring the environment
Before installing MailEnable, ensure that the environment has been configured correctly. This includes configuring network connectivity and the Public DNS Server. MailEnable should be configured in an environment with a static IP address but (although not recommended) can be configured to work in environments with dynamic IP addresses using products like dyndns or dns2go, etc.

1. Before installing MailEnable, ensure that the machine can access the Internet (i.e.: ping www.mailenable.com ).
Ensure that other computers can ping the server's IP Address from the Internet (note: technically computers do not need to be able to ping the server, but they will definitely need to be able to connect to TCP/IP Ports 110 and 25 of the server). In most cases, this requires some firewall configuration. For those unfamiliar with configuring firewalls, the best approach is to open all ports and then secure the server by blocking access to specific ports or services as appropriate. If experiencing difficulties with configuring the firewall, consult the respective manuals/resources associated with the operating system and communications infrastructure.

2. Ensure that the correct entries are registered in the DNS. The first step to doing this is to determine who has control of your public DNS records. Contact your ISP or DNS provider to determine who holds the records for the domain. This will allow you to determine who can create new DNS records for the domain. When hosting mail for a domain, each domain being hosted requires a number of DNS records to be created.

It is important to understand the role of DNS and how it relates to running mail servers.

Installing the MailEnable software
Now that the environment is configured, MailEnable can be installed. The product manuals explain how to install MailEnable.  These are installed with the product or available from our website here: http://www.mailenable.com/references.asp

Once MailEnable has been installed, check the MailEnable Diagnostic Report to ensure that all services are configured correctly.

Configuring the MailEnable software
MailEnable provides a 'quick start' guide with basic instructions on configuring and running the MailEnable software.
Quick Start Guide: http://www.mailenable.com/support/MailEnable_Quick_Start_Guide.pdf

Exploring and configuring MailEnable features
Each version of MailEnable has specific features. Review the manual of each respective edition to review and configure some of the more advanced features. See http://www.mailenable.com/references.asp