Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been using useradd to create user account on my CentOS server although cPanel has been installed on the server. For some reasons, I created them by command instead of using WHM.

Now, some of them want to use rich features of cPanel. What is the best solution here to add those account using cPanel without re-creating them through WHM?

share|improve this question

closed as off-topic by HopelessN00b Jan 13 '15 at 22:22

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

This question appears to be off-topic because it is about working with a service provider's management interface, such as cPanel. – HopelessN00b Jan 13 '15 at 22:22
There is a way to do that… – JackTheKnife Mar 25 '15 at 14:52
up vote 0 down vote accepted

cPanel creates a whole wack of configuration files when you run through the Create Account Wizard so doing this process by hand would likely be more time-consuming and tedious than it would be to use the Wizard. That being said, if you only have home directory data to worry about for each user, you can easily just hack together a Bash script (like the one below :)) to move the home directory data out of the way (say /home/user.bak), kill the account (userdel -r user), create the account,and finally move the data back. Note that if the home directory for the user contains web content, under the cPanel directory schema, that content needs to be moved into ~/public_html.

Here's a very simple bash script, which takes a list of accounts from a text file and does what I mentioned above. Note the text file is formatted as cPanel won't create an account without a domain name. You'll have to setup this mapping manually when you create that file or come up with a way to script using awk/grep from your existing config. The script also creates a password for all of the accounts of 'temppass' -- make sure you change that! :)


# Replace this with the file you use

for USER in `awk -F':' {'print $2'} $FILE`
  mv /home/$USER /home/$USER.bak
  userdel -r $USER
  DOMAIN=`grep $USER|awk -F':' {'print $1'}`
  /scripts/createacct $DOMAIN $USER temppass
  cp -a /home/$USER.bak/* /home/$USER/
  #Uncomment this if you're sure you want to remove the old dir
  # rm -rf /home/$USER.bak
share|improve this answer
Thanks gman, I actually thought about userdel then create them again in WHM, but the problem with old password removed as well is way too bad. Is it a good idea to notify them about temp password and force them to create a new one? – thatlamguy Apr 6 '12 at 3:08
You could add a little extra to the script where you pull the password hash from /etc/passwd before deleting the account and then replacing it after the createacct script is run. Otherwise just use the Password Modification function in the WHM. – Garrett Apr 6 '12 at 4:05
This is from cPanel forum: "Allowing this would permits users to bypass password strength checking as the password would be opaque to the interface."… Yes, we are able to pull those password hash from shadow file, but cannot figure out how to insert the hashed password to WHM. – thatlamguy Apr 6 '12 at 6:15
Password checking just enforces a particular password strength. If you're satisfied with your particular password setup, then that's not a problem. What would be a problem here is setting the MySQL and FTP passwords, as they use different hashing mechanisms, and there's no way to pass a hashed password to the WHM. – Garrett Apr 6 '12 at 15:01
thanks for your help gman! – thatlamguy Apr 8 '12 at 6:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.