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

Ask all your questions regarding OC 4.x and older. Please read the Support Forum Rules
Forum rules
Before you post; make sure you are using at least PHP Version 5.3.x - Also read How To Solve Problems By Yourself

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

Postby santigua » Thu Apr 05, 2012 10: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 7:08 pm

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

Postby santigua » Sun Apr 08, 2012 8: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)
santigua
Beginner
 
Posts: 22
Joined: Mon Jan 23, 2012 7:08 pm

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

Postby Baggypants » Sun Apr 08, 2012 11:27 pm

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?
Baggypants
Starter
 
Posts: 54
Joined: Fri Feb 10, 2012 11:38 pm

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

Postby tschoie » Mon Apr 09, 2012 8: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
tschoie
Beginner
 
Posts: 21
Joined: Tue Feb 28, 2012 7:39 pm

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

Postby nkoehring » Mon Jun 11, 2012 2: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.
nkoehring
Newbie
 
Posts: 1
Joined: Mon Jun 11, 2012 2:36 am

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

Postby magista » Sat Jun 23, 2012 11:23 am

Its not working on my installation,

Code: Select all
select * from oc_preferences where configkey="lostpassword"


gets an empty result.
magista
Beginner
 
Posts: 18
Joined: Fri Mar 09, 2012 12:02 pm

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

Postby danielw » Sat Jul 14, 2012 1: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!
danielw
Newbie
 
Posts: 1
Joined: Sat Jul 14, 2012 1:01 pm

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

Postby ladiko » Tue Feb 19, 2013 4: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
ladiko
Newbie
 
Posts: 2
Joined: Mon Feb 11, 2013 2:14 pm
OwnCloud version: 4.5.4


Return to OwnCloud Community Edition 4.x and older

Who is online

Users browsing this forum: Bing [Bot] and 6 guests