Reset admin password in nextcloud

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
What is the command for resetting the admin password
su -u www php /usr/local/www/nextcloud/occ user:resetpassword admin doesn't work
and su -m www -c 'php /usr/local/www/nextcloud/occ user:resetpassword admin' doesn't work either.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
su -u www php /usr/local/www/nextcloud/occ user:resetpassword admin doesn't work
What does it do? Saying "it doesn't work" doesn't give any idea of what's going wrong, you know. The second command you list looks correct in form, assuming you have the correct path to occ.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
What does it do?
Code:
su -u www php /usr/local/www/nextcloud/occ user:resetpassword admin
su: illegal option -- u
usage: su [-] [-flms] [-c class] [login [args]]


Code:
root@nextcloudS:/usr/local/www/nextcloud # ls -l
total 197
-rw-r--r--   1 www  www   2824 Apr  8 18:47 .htaccess
-rw-r--r--   1 www  www	163 Mar 13 14:47 .user.ini
drwxr-xr-x  33 www  www	 41 Mar 13 14:55 3rdparty
-rw-r--r--   1 www  www  12063 Mar 13 14:47 AUTHORS
drwxr-xr-x  36 www  www	 36 Mar 13 14:48 apps
drwxr-xr-x   2 www  www	  5 Apr  8 18:46 config
-rw-r--r--   1 www  www   3593 Mar 13 14:47 console.php
drwxr-xr-x  17 www  www	 23 Mar 13 14:55 core
-rw-r--r--   1 www  www   4946 Mar 13 14:47 cron.php
drwxr-xr-x   2 www  www	  5 Apr  8 18:47 data
-rw-r--r--   1 www  www	179 Mar 13 14:47 index.html
-rw-r--r--   1 www  www   3417 Mar 13 14:47 index.php
drwxr-xr-x   6 www  www	  9 Mar 13 14:47 lib
-rw-r--r--   1 www  www	283 Mar 13 14:47 occ
drwxr-xr-x   2 www  www	  5 Mar 13 14:47 ocs
drwxr-xr-x   2 www  www	  3 Mar 13 14:47 ocs-provider
-rw-r--r--   1 www  www   3214 Mar 13 14:47 public.php
-rw-r--r--   1 www  www   5370 Mar 13 14:47 remote.php
drwxr-xr-x   4 www  www	  4 Mar 13 14:47 resources
-rw-r--r--   1 www  www	 26 Mar 13 14:47 robots.txt
drwxr-xr-x  14 www  www	 19 Mar 13 14:47 settings
-rw-r--r--   1 www  www   2274 Mar 13 14:47 status.php
drwxr-xr-x   3 www  www	  4 Mar 13 14:47 themes
drwxr-xr-x   2 www  www	  4 Mar 13 14:48 updater
-rw-r--r--   1 www  www	362 Mar 13 14:54 version.php

 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
su: illegal option -- u
...and what does the second command do? The first one you posted would be the correct form for sudo, but not for su. But su -m should be correct.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
...and what does the second command do? The first one you posted would be the correct form for sudo, but not for su. But su -m should be correct.
Code:
 su -m www php /usr/local
/www/nextcloud/occ user:resetpassword admin
php: No such file or directory.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
So the php binary isn't in the system path. Looks like you need to find it.
Ok so I ran locate php and found it is in the /var/run directory so I ran the 2nd command I posted after entering the /var/run directory and it asked me for a new password. Success.

1)What I don't understand is why commands like those below worked and could find php.

su -m www -c 'php /usr/local/www/owncloud/occ config:system:set memcache.local --value="\OC\Memcache\APCu"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set memcache.locking --value="\OC\Memcache\Redis"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set redis host --value="/tmp/redis.sock"'
su -m www -c 'php /usr/local/www/owncloud/occ config:system:set redis port --value=0 --type=integer'


2)The passwords were generated by your script and saved to /root/db_password.txt but the file doesn't exist anymore. Was it automatically deleted?
3) I can get the mysql db password from the nextcloud/config/config.php is there a way to get the root password?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I ran locate php and found it is in the /var/run directory
? If you used the php packages, it should be in /usr/local/bin/php (which should be in your path):
Code:
[root@nextcloud ~]# which php
/usr/local/bin/php

The passwords were generated by your script and saved to /root/db_password.txt but the file doesn't exist any more.
That file is in your FreeNAS system, not in the jail. Once the script has run, there shouldn't be anything that automatically removes it.
I can get the mysql db password from the nextcloud/config/config.php is there a way to get the root password?
Inside the jail, it's in /root/.my.cnf.
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739
? If you used the php packages, it should be in /usr/local/bin/php (which should be in your path):
Code:
root@nextcloudS:~ # echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
root@nextcloudS:~ # which php
/usr/local/bin/php

/usr/local/bin is already in my path

That file is in your FreeNAS system, not in the jail.
Every once in a while I forget that I'm in a jail or in the FreeNAS system by mistake. Sorry.

My /root/.my.cnf file has this in it.
Code:
[server]
skip-networking
skip-name-resolve
expire_logs_days = 1
innodb_flush_method = O_DIRECT
skip-innodb_doublewrite
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table


Thanks for your help
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
My /root/.my.cnf file has this in it.
That's odd. Here's mine (and yes, I realize I'm sharing the password here; I just destroyed that jail, so there's no exposure):
Code:
# MySQL client config file
[client]
password=fvT++SOpE8x9L7LIf/oqbQ==

...and here's the contents of the template that it uses:
Code:
[client]	
# MySQL client config file	
password=mypassword

If you were using my script, I have no idea where those contents would have come from.

From inside the jail, as root, what happens if you just run mysql?
 

NasKar

Guru
Joined
Jan 8, 2016
Messages
739

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
and he has you edit the /usr/local/etc/my.cnf with the contents I listed above.
Ah, that explains it. I'd still suggest adding the password line to /root/.my.cnf; should you need to do anything with the database from inside the jail, it will make it a lot easier.
 

rwillett

Dabbler
Joined
Feb 18, 2015
Messages
37
I'm adding this line as it shows the exact solution to the problem of forgetting the admin password when setting up NextCloud. The NextCloud documentation is a little terse so it took longer to work it out.

The solution I used.

Code:
ssh <username>@<freenas_ip_address>

sudo su - 

su -m www -c 'php /usr/local/www/nextcloud/occ user:resetpassword <PUT YOUR ADMIN USER NAME IN HERE>'
The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php
Enter a new password:
Confirm the new password:
Successfully reset password for nc_admin

It wasn't clear to me as a new user of FreeBSD and NextCloud what the occ command did. I thought I had to substitute my username and resetpassword in the user:resetpassword section of occ and that the admin at the end meant admin user. I know it's a stupid mistake but I made it so perhaps this will stop somebody else making it.
 

EsTaF

Contributor
Joined
Sep 20, 2013
Messages
163
Code:
su -m www -c 'php /usr/local/www/nextcloud/occ user:resetpassword root'

The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php

The current PHP memory limit is below the recommended value of 512MB.

Nextcloud is not installed - only a limited number of commands are available



                                                          

  There are no commands defined in the "user" namespace. 
 

EsTaF

Contributor
Joined
Sep 20, 2013
Messages
163
Give back owncloud please. the well performing services, that were before.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
You've necro'd two threads that have nothing to do with your problem, to complain about Nextcloud. If you're having a problem with it, why not start your own thread, in the appropriate subforum, explaining just what's going on and what you did to get to that step. Or install Owncloud, if you think that will help.
 
Top