Education ChannelsWHM

Split a single cPanel account into multiple accounts using SSH

This article presents an advanced technique for dividing a single cPanel account into multiple cPanel accounts. This feature is only available on VPS or dedicated server plans, and dividing your domains among different cPanel accounts can enable you to grant cPanel access to a website owner without giving them access to your other domains.

The example below features a single cPanel account named userna1, with the primary domain name and an addon domain name, Our objective is to separate these two domains to provide a web developer with complete cPanel and FTP access to, without allowing them to alter anything on our site.

Since we have a WordPress installation on both domains, we must ensure that the MySQL database is transferred, and the database user credentials are modified to allow the database connection to function with a new username.

Please note that cPanel creation is no longer unrestricted. To learn more about cPanel Pricing Changes and related FAQs, please refer to the relevant resources.

To follow the instructions in this article, you must have root access to your server. If you do not have root access, you may also use our more basic article on how to split a single cPanel account into multiple ones.

Login to your server via SSH as the root user.
We want to find the document root for our and then change to that directory with these commands: grep /etc/userdatadomains
Which should give us back:

Now change to the directory in-between the ==’s with:

cd /home/userna1/public_html/

Now we want to look for any database configurations on this domain, an easy way is to look for the username followed by an underscore _ through all your files with the following command: grep userna1_ ./ -RH
Which should give back something similar to:

./wp-config.php:define(‘DB_NAME’, ‘userna1_wrdp1’);
./wp-config.php:define(‘DB_USER’, ‘userna1_wrdp1’);

So we can see because of wp-config.php that these database credentials are for a WordPress site, you’ll want to open up this file and also copy down the DB_PASSWORD value as well as the DB_NAME and DB_USER ones.

Now we want to backup that WordPress database to our home directory using the following command: mysqldump userna1_wrdp1 > ~userna1/userna1_wrdp1.sql
We can now create our new cPanel account. The first thing you’ll want to do is Log into WHM.
In the top-left Find box type in Create, then click on Create a New Account.

Now for the Domain: you’ll want to enter your domain with a suffix, that way we can test and get the account up and running prior to shutting down the real site. So in our example we’re using, you can then choose a username and password you’d like this new cPanel to use, and in the Choose a Package drop-down you’ll want to select the default vpspackage or whatever custom package you might have set up.After entering in all the information scroll to the bottom of the page and click on Create

Now that the new account is created we want to copy over all of the relevant files for the site to the new userna2 account with the following series of commands: rm -rf ~userna2/public_html
cp -frp ~userna1/etc/ ~userna2/etc/

cp -frp ~userna1/mail/ ~userna2/mail/

cp -frp ~userna1/mail/.*@addondomain_com ~userna2/mail/

cp -frp ~userna1/public_html/ ~userna2/public_html

Now we want to fix the permissions of all the files we brought over, so they’re owned by the userna2 user with the following command:

fixperms userna2

Now we want to update our wp-config.php script so it’s using our new userna2 username, this can be done with the following command: replace userna1_ userna2_ — ~userna2/public_html/wp-config.php
Which should spit back:

/home/userna2/public_html/wp-config.php converted

Now Login to your cPanel so you can create the MySQL database.
Under the Databases section click on MySQL Database Wizard.

Enter the database name from our wp-config.php script, then click on Next Step.

Enter in a database username and password, then click Create User.

Place a check beside All Privileges, then click Next Step.

Now back to our SSH session we can import our MySQL backup into the newly created userna2_wrdp1 database with the following command: mysql -u userna2_wrdp1 -p userna2_wrdp1 < ~userna1/userna1_wrdp1.sql
At the Enter password: prompt, enter in the database user password you copied down earlier.

Now you’ll want to login to your original cPanel account again to remove the from the account, so that we can modify the one we created on our new account. To start this process under the Domains section click on Addon Domains.

Beside click on Remove.

On the confirmation screen click on Remove “”.

Now that the domain is removed from our userna1 cPanel account, we’ll want to log back into WHM so we can modify our userna2 account to use that domain. In the top-left Find box type in modify, then click on Modify an Account.

Click on our domain, then click on Modify.

Now change the domain entry in the Primary Domain: field to, then scroll to the bottom and click on Save. You should see a green Success! status display when it’s done.
This should be all that is necessary for splitting one cPanel account into multiple cPanel accounts. Once you have everythign running correctly on the new separate cPanel account, you can then go back to the original userna1 cPanel account and remove the site’s files from /etc/, /etc/, and /public_html/ Also you can remove the MySQL database from that user as well now that a duplicate copy has been setup under our new userna2 user.

For a simpler method on a Shared Hosting account, try to just create extra logins for appropriate tools.



Leave a comment

Your email address will not be published.Required fields are marked *