Sunday, June 22, 2014

Recovering my OwnCloud admin user password

Because of its endless awesomeness, I'm running an ownCloud instance on my server at home.
What I'm actually using of it is the WebDAV frontend to up/download stuff from Android (the native ownCloud App seems to have problems with really big files, such as several hundred MB) and the "instant upload" feature for the android camera, to automatically upload photos for easy reusing on the PC.

Today I wanted to configure some stuff and found out that I had totally forgotten the admin password, simply because I never needed it after the initial setup.

Modern applications no longer just store the passwords in the database, so it's not as simple as it could be. Additional problems arise from the fact that I have basically zero database knowledge.
Fortunately, I still knew that I'm using a mariadb on the server...

So that's what I did to restore admin access:

  • cat config/config.php, note values of "dbuser" and "dbpassword"
  • mysql -u <dbuser> -p;
    • paste <dbpassword>
  • show databases;
    • note that there is a database called "owncloud", which is probably the one I need...
  • use owncloud;
  • select * from oc_users;
    • Oh! My admin user is called "root", not "admin" as I would have guessed... Important information. So I try to use the password reset from the web form for user "root", however, it does not work...
  • select * from oc_preferences;
    • Oh! "root" has no email address configured, no wonder the password reset does not work.
    • After some searching, I found the way to the solution in the ownCloud forum:
  • INSERT INTO `oc_preferences` ( `userid` , `appid` , `configkey` , `configvalue` ) VALUES ( 'root','settings','email','root@localhost' );
And voilà: the password reset link is working, root get's an email which contains the link to set a new password. Life is good again :-)

No comments:

Post a Comment