how to reset admin password (oc3, debian6, sqlite)

Ask all your questions regarding OC 5.x Please read the Support Forum Rules
Forum rules
ownCloud 5.x reached end of life and is officially unsupported. For details see Wiki page.

Please upgrade your ownCloud.
santigua
Beginner
Posts: 22
Joined: Mon Jan 23, 2012 8:08 pm

how to reset admin password (oc3, debian6, sqlite)

Postby santigua » Thu Apr 05, 2012 11:28 pm

how do I reset the OC-admin password ? Apparently I forgot to set a proper email-address.

root access to the system itself, by the way, is available. ;)

System ist running oc3 on a debian6 with sqlite.

thanx
___
Server: ownserver running debian6 with apache2, sqlite, PHP 5.3.3 and oc3.0
Client: OSX 10.6.8 with firefox or cyberduck (finder creates 0 Byte-files)

santigua
Beginner
Posts: 22
Joined: Mon Jan 23, 2012 8:08 pm

Re: how to reset admin password (oc3, debian6, sqlite)

Postby santigua » Sun Apr 08, 2012 9:06 pm

since the seems to be no way for recovery or resetting the password, I'm pretty happy, that >2h of "brute-force-attacking" (trying any word and any permutation I could think of) ....I finally could get in and set a proper email address.

I know it was my own fault in deed, but... is there really no way to recover, or at least reset the oc-admin-password using machines root-access ???
___
Server: ownserver running debian6 with apache2, sqlite, PHP 5.3.3 and oc3.0
Client: OSX 10.6.8 with firefox or cyberduck (finder creates 0 Byte-files)

Baggypants
Starter
Posts: 54
Joined: Sat Feb 11, 2012 12:38 am

Re: how to reset admin password (oc3, debian6, sqlite)

Postby Baggypants » Mon Apr 09, 2012 12:27 am

Here is one way how you can do it

Delete config/config.php

In the DB remove the row containing uid=admin from table oc_users. I know nothing about sqlite, mine is on MySQL

reload the main page in the browser. It will give you the initial setup page again and ask you to create an admin user password.

I suppose the setup page could ask you to put an email address in when you create the admin account. But where would the fun be in that?

tschoie
Beginner
Posts: 23
Joined: Tue Feb 28, 2012 8:39 pm

Re: how to reset admin password (oc3, debian6, sqlite)

Postby tschoie » Mon Apr 09, 2012 9:46 am

Alternatively, you can "inject" a newly created, changed password directly into the database. Use

Code: Select all

echo -n "password" | sha1sum
to create the SHA1-checksum of your new "password" and simply overwrite the relevant user's password cell in the database. (At some point in the future the password hashes should be salted, really.)

Cheers,
tschoie

nkoehring
Newbie
Posts: 1
Joined: Mon Jun 11, 2012 3:36 am

Re: how to reset admin password (oc3, debian6, sqlite)

Postby nkoehring » Mon Jun 11, 2012 3:48 am

The post is a bit older but I want to show you and the following people another way of resetting the admin password without changing the database directly. What you need is a way to read the database thats used by ownCloud.

  • Use the password reset functionality of ownCloud. Don't bother about the existence of an email address.
  • Connect to your database (eg using sqlite or mysql).
  • Type:

    Code: Select all

    select * from oc_preferences where configkey="lostpassword";
  • You will get something like:

    Code: Select all

    username|owncloud|lostpassword|4a08768105c0c4c44ac7ac9ef40a4c7e76eab333
  • To get exactly what you need, you could also use:

    Code: Select all

    select configvalue from oc_preferences where configkey="lostpassword" and userid="admin";
  • Use the returned token in following link:
    https://YOUR.OWNCLOUD.URL/core/lostpassword/resetpassword.php?user=admin&token=TOKEN


I hope that helps a bit.

magista
Beginner
Posts: 25
Joined: Fri Mar 09, 2012 1:02 pm

Re: how to reset admin password (oc3, debian6, sqlite)

Postby magista » Sat Jun 23, 2012 12:23 pm

Its not working on my installation,

Code: Select all

select * from oc_preferences where configkey="lostpassword"


gets an empty result.

danielw
Newbie
Posts: 1
Joined: Sat Jul 14, 2012 2:01 pm

Re: how to reset admin password (oc3, debian6, sqlite)

Postby danielw » Sat Jul 14, 2012 2:06 pm

Hi all, I managed to reset the password of my admin account like this:

Code: Select all

[root@server ~]# echo -n "new-password" | sha1sum

[root@server ~]# cd var/www/html/owncloud/data/
[root@server data]# sqlite owncloud.db

sqlite> select * from oc_users;
sqlite> UPDATE oc_users SET password = 'NEW_SHA1SUM' WHERE password = 'OLD_SHA1SUM';
sqlite> .quit


Hope this helps anyone out there!

ladiko
Newbie
Posts: 5
Joined: Mon Feb 11, 2013 3:14 pm
ownCloud version: 4.5.4

Re: how to reset admin password (oc3, debian6, sqlite)

Postby ladiko » Tue Feb 19, 2013 5:06 pm

thanks! this helped, didnt thought about the "-n" option for echo, but your hint helped importing all my users to ownclouds SQLite database. So here is part of my script that connects via ssh to a webserver and adds a user + password, email and set group admin.

Code: Select all

USERNAME="testuser"
PASSWORD="123zxc,./"
SHA1SUM=`echo -n "${PASSWORD}" | sha1sum | awk '{print $1}'`
REMOTE_SSH="ssh remove-server.mydomain.abc"

echo "insert $USERNAME into owncloud.db"
if $REMOTE_SSH "sqlite3 /var/www/owncloud/data/owncloud.db \"select * from oc_users\"" | grep -q ${USERNAME} ; then
      echo -e "\t${USERNAME}: already exists in owncloud.db"
else
      $REMOTE_SSH "sqlite3 /var/www/owncloud/data/owncloud.db \"insert into oc_users values('${USERNAME}','${SHA1SUM}')\""
fi

if $REMOTE_SSH "sqlite3 /var/www/owncloud/data/owncloud.db \"select * from oc_preferences\"" | grep -q ${USERDOTNAME} ; then
      echo -e "\t${USERNAME}: email already set in owncloud.db!"
else
      $REMOTE_SSH "sqlite3 /var/www/owncloud/data/owncloud.db \"insert into oc_preferences values('${USERNAME}','settings','email','${USERDOTNAME}@mydomain.abc$
fi

if $REMOTE_SSH "sqlite3 /var/www/owncloud/data/owncloud.db \"select * from oc_group_admin\"" | grep -q ${USERNAME} ; then
      echo -e "\t${USERNAME} is already group admin in owncloud.db!"
else
      $REMOTE_SSH "sqlite3 /var/www/owncloud/data/owncloud.db \"insert into oc_group_admin values('customer','${USERNAME}')\""
fi

S-Holzhauer
Newbie
Posts: 1
Joined: Mon Dec 30, 2013 12:27 pm
ownCloud version: 6.0.0a
Webserver: Apache
Database: MySQL
OS: Unknown
PHP version: 5.4

Re: how to reset admin password (oc3, debian6, sqlite)

Postby S-Holzhauer » Mon Dec 30, 2013 12:34 pm

Above solutions seem not to work with owncloud 6.0. I'm not sure but I suppose that both passwords and tokens are salted now.

I solved the issue by manually inserting an email address for the user in order to reset the password:

Code: Select all

INSERT INTO `db`.`oc_preferences` (
`userid` ,
`appid` ,
`configkey` ,
`configvalue`
)
VALUES (
'admin', 'settings', 'email', 'email@domain'
);

porkopops
Newbie
Posts: 1
Joined: Mon Jan 13, 2014 9:34 pm

Re: how to reset admin password (oc3, debian6, sqlite)

Postby porkopops » Mon Jan 13, 2014 9:38 pm

Or you can create an SHA1 hash of a new password on a publicly available website and update:

oc_users > password, for the admin user.

This worked OK for me.

Paul


  • Similar Topics
    Replies
    Views
    Last post

Return to “ownCloud Community Edition 5.x and older”

Who is online

Users browsing this forum: No registered users and 1 guest