I will give an example of setting up two-factor authentication in Nextcloud using Google Authenticator.
First we need to install the application, for example, “Two-Factor TOTP Provider”, for this we open the application menu in the Nextcloud web interface, find it in the “Security” tab and install it.
Create backup codes in case you don’t have access to Google Authenticator, you can create them in the Nextcloud settings, in the “Personal” menu – “Security”, and in the same place tick the “Enable TOTP” box.
Open the Google Authenticator app on your smartphone and scan the code.
Now we will enable globally two-factor authentication in the “Administration” – “Security” and tick the “Require two-factor authentication” checkbox.
If you do not specify groups, two-factor authentication will be enabled for all groups.
See also my article:
Install Nextcloud in Ubuntu