How to Recover/Reset owncloud admin Password

I have installed owncloud 6.0 for testing purpose and later a stage i upgraded to 7.0 & 8.0 but i forget to assign the email id for password reset request and now i forget my owncloud admin password and trying to reset. I have spend lots of time on owncloud forum and found few more solution. In my point of view the below one is very simple and effective. See the below steps to reset the owncloud admin password.

1) Reset Owncloud 7 & 8 Admin password

To reset owncloud 7 & 8 admin password, we can use the occ command to reset the password which will uses HTTP user, follow the below procedure. Make sure you have to mention your owncloud installation directory insteadof us /var/www/dev.2daygeek.com/public_html/owncloud/occ.

# For Debian based Systems #
$ sudo -u www-data php /var/www/dev.2daygeek.com/public_html/owncloud/occ user:resetpassword admin
Enter a new password:
Confirm the new password:
Successfully reset password for admin

# For RHEL based Systems #
$ sudo -u apache php /var/www/dev.2daygeek.com/public_html/owncloud/occ user:resetpassword admin
Enter a new password:
Confirm the new password:
Successfully reset password for admin

# For openSUSE Systems #
$ sudo -u www php /var/www/dev.2daygeek.com/public_html/owncloud/occ user:resetpassword admin
Enter a new password:
Confirm the new password:
Successfully reset password for admin

owncloud-7-8-admin-password-reset-centos-fedora-rhel-opensuse-ubuntu-mint-debian

1) Reset Owncloud 6 Admin password

To reset owncloud 6 admin password, follow the below procedure. Navigate to your owncloud installation directory & open config/config.php file and passwordsalt value. It will use later a stage.

# cd /var/www/dev.2daygeek.com/public_html/owncloud/config
# nano config.php                                                                   

$CONFIG = array (
  'instanceid' => 'ocad6719eb29',
  'passwordsalt' => 'f1f4ffb343483cae0fcc2f6d8d6797',
  'trusted_domains' =>
  array (
    0 => 'owncloud.2daygeek.com',
  ),
  'datadirectory' => '/var/www/dev.2daygeek.com/public_html/owncloud/data',
 );

2) Navigate to phpass directory

Navigate to your phpass directory. Open test.php file and comment below orange colour lines and add green coloured line value newely under the orange colour line. Make sure you need to add your new password instead of admin123 and your passwordsalt value which we noted in step2. Save and exit.

# cd /var/www/dev.2daygeek.com/public_html/owncloud/3rdparty/phpass
# nano test.php

# Try to use stronger but system-specific hashes, with a possible fallback to
# the weaker portable hashes.
#$t_hasher = new PasswordHash(8, FALSE);
$t_hasher = new PasswordHash(8, CRYPT_BLOWFISH!=1);

#$correct = 'test12345';
$correct = 'admin123'.'f1f4ffb343483cae0fcc2f6d8d6797';
$hash = $t_hasher->HashPassword($correct);

print 'Hash: ' . $hash . "\n";

4) Run the test.php file

After made above change, Run the test.php file. Like below and it will shows below result’s. Make sure you need to copy the First Hash value which is start value like $2….

# php test.php
Hash: $2a$08$7nZBhzaJVMPqMICMrXMKQOEvmQ47z5QtQ4FxPSWv5ecRIvRq7j332
Check correct: '1' (should be '1')
Check wrong: '' (should be '0' or '')
Hash: $P$BJ4/Sgm8k9lsH1xgZMx9KGzlQvDuM3.
Check correct: '1' (should be '1')
Check wrong: '' (should be '0' or '')
Hash: $P$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0
Check correct: '' (should be '1')
Check wrong: '' (should be '0' or '')
Some tests have FAILED

Note : After done this, you can remove the new changes which you made on your test.php file.

5) Update the new password to admin user

Login to mysql server and navigate to owncloud database and run the below command to update the admin password.

# mysql -u root -p
mysql> use owncloud_cloud;
mysql> UPDATE `oc_users` SET `password` = '$2a$08$7nZBhzaJVMPqMICMrXMKQOEvmQ47z5QtQ4FxPSWv5ecRIvRq7j332' WHERE `uid` = 'admin';

6) Owncloud password reset successful

Now, you have successfully reset your owncloud password, just navigate on your owncloud installation url on browser and login into your admin account using your new password. In my case new password is admin123 and play it.
how-to-recover-reset-owncloud-admin-password-1
We are preparing all articles in-depth to understand by all level/stage Linux administrators. If the article is useful for you, then please spend less than a minute to share your valuable comments in our commenting section.

Please stay tune with us…Good Luck.

About Magesh Maruthamuthu

Love to play with all Linux distribution

View all posts by Magesh Maruthamuthu

19 Comments on “How to Recover/Reset owncloud admin Password”

        1. @Rachid,
          I have tested on Owncloud 6.x series and it wont work with 8.x.

          For 8.x we need to follow the below steps.

          $ sudo -u www-data php ../owncloud/occ user:resetpassword admin
          Enter a new password:
          Confirm the new password:
          Successfully reset password for admin

          Apache user’s for Linux Distro
          ================================
          Centos, Red Hat, Fedora: apache:apache
          Debian, Ubuntu, Linux Mint: www-data:www-data
          openSUSE: wwwrun:www

          I have tried in Ubuntu 15.10 and its working fine, will check with othe major distro and create separate article.

  1. Can anyone tell me how to do step 5 via cPanel. I have managed to do steps 1 thru 4 via cPanel but stuck at step 5. I have NO idea about logging into server as root etc etc. I only know cPanel

    Thanks
    Clint

    PS Im desperate!!!!!

  2. There is easier way:
    In owncloud site root directory enter
    sudo -u [web-server-user] php console.php user:resetpassword [owncloud-login]
    This will ask for new password and update it

    1. Hi,
      If you could please help. It seams that mentioned command gives me an error:

      root@oblak:/var/www/owncloud/config# clear
      root@oblak:/var/www/owncloud/config# sudo -u oblak php console.php user:resetpassword oblak
      sudo: unknown user: oblak
      sudo: unable to initialize policy plugin
      root@oblak:/var/www/owncloud/config#

      Thank you very much for the help.

Leave a Reply to Ramya Nuvvula Cancel reply

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