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.

How to organize massive passwords change on cpanel server?

Discussion in 'General Discussion' started by ATsukanov, Jun 20, 2007.

  1. ATsukanov

    ATsukanov Registered

    Joined:
    Nov 22, 2004
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    I need to change all passwords for user account on cpanel server. Is it possible to do it automatically by using some cpanel script? Also I need this information stored in one file in order to know new passwords.

    Thanks!
     
  2. elleryjh

    elleryjh Well-Known Member

    Joined:
    Apr 12, 2003
    Messages:
    479
    Likes Received:
    0
    Trophy Points:
    16
    You want to change all user accounts' passwords, right?


    You can change an account's password by loading the URL

    http://root:<rootpass>@domain:2087/scripts/passwd?user=<username>&password=<password>

    So, if you have a PHP script with the passwords like this:

    PHP:
    $userpass = array("user1" => "pass1""user2" => "pass2");
    Then you can automate it like this running php on the same server:

    PHP:
    foreach($userpass as $user=>$pass){
    file_get_contents("http://root:<rootpass>@localhost:2087/scripts/passwd?user=$user&password=$pass");
    }
    And some caviats....

    It requires fopen url wrappers. If not enabled, use curl, etc.

    Having the root password in plaintext is dangerous, so make sure this file is not world readable, and delete it afterwards.

    The foreach loop doesn't check for success or anything, so if you have an invalid account or empty password, it won't tell you.
     
Loading...

Share This Page