Yunohost 2FAuth Failed

What type of hardware are you using: Other(?)
What YunoHost version are you running: 12.0.17
What app is this about: 2FAuth

Describe your issue

I installed 2fauth and registered, but when I log in I get this error

Share relevant logs or error messages

An error occured:

Key path “file:///var/www/2fauth/storage/oauth-public.key” does not exist or is not readable

Hi,
Could you find this file in your Yunohost file system?

/var/www/2fauth/storage/oauth-public.key

It seems it is just a problem of access, according to this site

So try

sudo chown www-data:www-data storage/oauth-*.key

yes when I access as root the file seems to be available

chown: cannot access ‘storage/oauth-*.key’: No such file or directory

This isn’t the correct ownership for the yunohost app:

ls -lha /var/www/2fauth/storage/oauth-p*
-rw-r----- 1 2fauth www-data 3.3K Mar 22  2024
 /var/www/2fauth/storage/oauth-private.key
-rw-r----- 1 2fauth www-data  812 Mar 22  2024
 /var/www/2fauth/storage/oauth-public.key

Can you share the install log (in the webadmin > tools >logs. Use the green share button).

the correct command shoud be:

sudo chown 2fauth:www-data /var/www/2fauth/storage/oauth-private.key

We also need

ls -lha /var/www/2fauth/storage/oauth-p*

there are no errors or problems where you say

what commands do I need to write to give you detailed information

Jarod5001 asks you to go on the Webadmin:

My 2fauth does not work at the moment either; there is no clear error: I just can not log in. The web console does not show anything, nor does the Laravel log or the nginx log.

After reading the hints in this thread, I checked file permissions on my server where I reinstalled 2fauth last week.

$ sudo ls -hals /var/www/2fauth/storage *
4.0K -rw------- 1 root   root     3.3K Jul  3 09:40 oauth-private.key
4.0K -rw-rw---- 1 root   root      812 Jul  3 09:40 oauth-public.key

There are no extended attributes to give access to 2fauth or www-data:

$ sudo lgetfacl /var/www/2fauth/storage/oauth-p*
# file: oauth-private.key
# owner: root
# group: root
user::rw-
group::---
other::---

# file: oauth-public.key
# owner: root
# group: root
user::rw-
group::rw-
other::---

I changed the ownership to match the example given by jarod5001:

$ sudo chown 2fauth:www-data :/var/www/2fauth/storage#/oauth-p*

It did not have an effect, I was still not able to log in to 2fauth. I realize that I did not restart nginx, but I do not think that should be necessary here.

I just removed and reinstalled the app to check whether the outcome (either success rate or file permissions) was any different; it is not:

  • unable to log in (“No account found using this email”) when using the email address given while installing 2fauth
  • oauth-*key are owned by root

To me this seems a problem that is introduced in newer versions, as I have used the app straight from the installation before (no idea since when, but… 2023-ish?) until it started to get blanked by updates.

@mystispy , sorry for hijacking your thread, I hope we can resolve this together! Welcome to the forums by the way :slight_smile:

PS, to follow up on the installation logs, see the log section that marc refers to:

Click your installation log to view details, and then the green “share” button:

Mine is at https://paste.yunohost.org/raw/vocawozera

Hi, can you another time show:

sudo ls -hals /var/www/2fauth/storage/
$ sudo ls -hals /var/www/2fauth/storage/
total 28K
4.0K drwxr-x---  5 2fauth www-data 4.0K Jul 11 21:57 .
4.0K drwxr-x--- 15 2fauth www-data 4.0K Jul 11 21:57 ..
4.0K drwxr-x---  5 2fauth www-data 4.0K Jun 18 08:08 app
4.0K drwxr-x---  6 2fauth www-data 4.0K Jun 18 08:08 framework
4.0K drwxr-x---  2 2fauth www-data 4.0K Jul 11 22:15 logs
4.0K -rw-------  1 root   root     3.3K Jul 11 21:57 oauth-private.key
4.0K -rw-rw----  1 root   root      812 Jul 11 21:57 oauth-public.key

This is without any modifications after installation

You still don’t have made the chown
why?

I did a reinstall last week, and earlier tonight (while writing the other post) I tested with the permissions changed. It did not have any effect.

The package could have had an update this week, so I reinstalled it to have the same version as mystispy (they got a step further than me, it seemed). Unfortunately, that does not seem the case.

$ sudo chown 2fauth:www-data /var/www/2fauth/storage/oauth-p*
$ sudo ls -hals /var/www/2fauth/storage/
total 28K
4.0K drwxr-x---  5 2fauth www-data 4.0K Jul 11 21:57 .
4.0K drwxr-x--- 15 2fauth www-data 4.0K Jul 11 21:57 ..
4.0K drwxr-x---  5 2fauth www-data 4.0K Jun 18 08:08 app
4.0K drwxr-x---  6 2fauth www-data 4.0K Jun 18 08:08 framework
4.0K drwxr-x---  2 2fauth www-data 4.0K Jul 11 22:15 logs
4.0K -rw-------  1 2fauth www-data 3.3K Jul 11 21:57 oauth-private.key
4.0K -rw-rw----  1 2fauth www-data  812 Jul 11 21:57 oauth-public.key
$ sudo systemctl reload nginx.service 

Does not make a change. Attempting to log in in a private window:

If you have an idea where to look, let me know! It’s bedtime here, so I’ll check back tomorrow.

try

php artisan passport:keys

or

php8.3 artisan passport:keys

according to
https://stackoverflow.com/questions/39414956/laravel-passport-key-path-oauth-public-key-does-not-exist-or-is-not-readable

4.0K drwxr-x— 5 2fauth www-data 4.0K Jul 11 06:39 .
4.0K drwxr-x— 15 2fauth www-data 4.0K Jul 11 06:39 ..
4.0K drwxr-x— 5 2fauth www-data 4.0K Jun 18 04:08 app
4.0K drwxr-x— 6 2fauth www-data 4.0K Jun 18 04:08 framework
4.0K drwxr-x— 2 2fauth www-data 4.0K Jul 11 06:40 logs
4.0K -rw------- 1 root root 3.3K Jul 11 06:39 oauth-private.key
4.0K -rw-rw---- 1 root root 812 Jul 11 06:39 oauth-public.key

the first command worked but the 2nd command did not

‘ls: cannot access ‘/var/www/2fauth/storage/oauth-p*’: No such file or directory’