I moved a nextcloud installation from one server to another. On the new server I want to use another version of PHP. The problem is that the passwords are hashed with the argon2 algorithm (in the tables oc_users
and oc_share
in the nextcloud
database).
The problem is that the new version does not seem to support argon2 and I get "wrong password" messages when I try to log in with the user+password on the new server that I know to work on the old server.
On the old server I was using PHP 7.2 from the remi repository; on the new server I would like to use PHP 7.2 or 7.3 (do not care) from the centos-sclo-rh repository.
user@home $ ssh old
user@old $ php --version
PHP 7.2.29 (cli) (built: Mar 17 2020 11:36:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.29, Copyright (c) 1999-2018, by Zend Technologies
user@old $ php -r 'var_dump(PASSWORD_ARGON2I);'
int(2)
user@old $ exit
user@home $ ssh new
user@new $ scl enable rh-php72 -- php --version
PHP 7.2.24 (cli) (built: Nov 4 2019 10:23:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24, Copyright (c) 1999-2018, by Zend Technologies
user@new $ scl enable rh-php73 -- php --version
PHP 7.3.11 (cli) (built: Dec 10 2019 16:14:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
user@new $ scl enable rh-php72 -- php -r 'var_dump(PASSWORD_ARGON2ID);'
Warning: Use of undefined constant PASSWORD_ARGON2ID - assumed 'PASSWORD_ARGON2ID' (this will throw an Error in a future version of PHP) in Command line code on line 1
string(17) "PASSWORD_ARGON2ID"
user@new $ scl enable rh-php73 -- php -r 'var_dump(PASSWORD_ARGON2ID);'
PHP Warning: Use of undefined constant PASSWORD_ARGON2ID - assumed 'PASSWORD_ARGON2ID' (this will throw an Error in a future version of PHP) in Command line code on line 1
string(17) "PASSWORD_ARGON2ID"
I also tried to install the sclo-php7{2,3}-php-sodium
and libsodium
because I found this: https://stackoverflow.com/a/59392421/4102092 but it did not help.
Finally the question: How can I use the PHP packages from the software collection repository and have argon2 support?
You can't.
The sodium extension provides the argon2 password hash algorithm only in PHP >= 7.4, not in previous versions.
In 7.2 / 7.3, argon2 is part of the "standard" extension and is disabled in RH build as libargon2 is not available in RHEL / CentOS
So this is the only solution for now.