Broken external storage

Nextcloud 21.0.3; PhP 8.0.8; Nginx 1.21.1 MariaDB 10.5
The issue you are facing:
When I go to re-configure my external storage I get the following error:

The server was unable to complete your request.

If this happens again, please send the technical details below to the server administrator.

More details can be found in the server log.
Technical details

Remote Address: 122.117.185.116
Request ID: AtL1kJngZ7vRtHc06dIl

I have recently upgraded to NC21 and had a number of external storage configured.
Running

root@stanworth-cloud:/var/www/nextcloud# sudo -u www-data php occ files_external:list

Shows they are still “there”

±---------±-------------------±-----------±----------------------±-------------------------------------------------------------------------------------------------------------------------------------±--------±-----------------±------------------+
| Mount ID | Mount Point | Storage | Authentication Type | Configuration | Options | Applicable Users | Applicable Groups |
±---------±-------------------±-----------±----------------------±-------------------------------------------------------------------------------------------------------------------------------------±--------±-----------------±------------------+
| 1 | /Recordings-cloud | SMB / CIFS | Username and password | host: “192.168.2.80”, share: “recordings”, root: “”, domain: “james2”, show_hidden: false, user: “stanworthcloud”, password: “" | | james2 | |
| 2 | /Client-Recordings | SMB / CIFS | Username and password | host: “192.168.2.80”, share: “recordings”, root: “Lab User”, domain: “labuser”, show_hidden: false, user: “labuser”, password: "
” | | labuser | admin |
| 9 | /SFTP | SFTP | RSA private key | host: “192.168.2.80:322”, root: “/archive”, user: “james”, password: “", private_key: "” | | james2 | |
±---------±-------------------±-----------±----------------------±-------------------------------------------------------------------------------------------------------------------------------------±--------±-----------------±------------------+

Is this the first time you’ve seen this error? _Yes - after upgrade

Steps to replicate it:

  1. Go to setting and external storage

The output of your Nextcloud log in Admin > Logging:

Error	PHP	Error: pack(): Type H: illegal hex digit - at /var/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Crypt/RSA.php#1147

    <<closure>>

    OC\Log\ErrorHandler::onError()

    /var/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Crypt/RSA.php - line 1147:

    pack()

    /var/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Crypt/RSA.php - line 1710:

    phpseclib\Crypt\RSA->_parseKey()

    /var/www/nextcloud/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php - line 61:

    phpseclib\Crypt\RSA->loadKey()

    /var/www/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php - line 94:

    OCA\Files_External\Lib\Auth\PublicKey\RSAPrivateKey->manipulateStorageConfig()

    /var/www/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php - line 132:

    OCA\Files_External\Config\ConfigAdapter->prepareStorageConfig()

    <<closure>>

    OCA\Files_External\Config\ConfigAdapter->OCA\Files_External\Config\{closure}("*** sensiti ... *")

    /var/www/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php - line 130:

    array_map()

    /var/www/nextcloud/lib/private/Files/Config/MountProviderCollection.php - line 109:

    OCA\Files_External\Config\ConfigAdapter->getMountsForUser()

    /var/www/nextcloud/lib/private/Files/Filesystem.php - line 452:

    OC\Files\Config\MountProviderCollection->addMountForUser()

    /var/www/nextcloud/lib/private/Files/Filesystem.php - line 377:

    OC\Files\Filesystem::initMountPoints()

    /var/www/nextcloud/lib/private/legacy/OC_Util.php - line 324:

    OC\Files\Filesystem::init()

    /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Auth.php - line 125:

    OC_Util::setupFS()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php - line 103:

    OCA\DAV\Connector\Sabre\Auth->validateUserPass("*** sensiti ... *")

    /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Auth.php - line 254:

    Sabre\DAV\Auth\Backend\AbstractBasic->check()

    /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Auth.php - line 156:

    OCA\DAV\Connector\Sabre\Auth->auth()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php - line 182:

    OCA\DAV\Connector\Sabre\Auth->check()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php - line 137:

    Sabre\DAV\Auth\Plugin->check()

    /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php - line 89:

    Sabre\DAV\Auth\Plugin->beforeMethod()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 456:

    Sabre\DAV\Server->emit()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 253:

    Sabre\DAV\Server->invokeMethod()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 321:

    Sabre\DAV\Server->start()

    /var/www/nextcloud/apps/dav/lib/Server.php - line 332:

    Sabre\DAV\Server->exec()

    /var/www/nextcloud/apps/dav/appinfo/v2/remote.php - line 35:

    OCA\DAV\Server->exec()

    /var/www/nextcloud/remote.php - line 167:

    require_once("/var/www/ne ... p")

(repeating)

I was confused for a bit because the forum ate your asterisks!

The error message is about the private key, so that’s where I’d start. To troubleshoot, you might try an SSH connection with just the password, if that’s allowed by the remote host. Once you’re sure that’s working, you can insert the private key again (from ~/.ssh/id_rsa?), and see what happens.
I’m not sure how Nextcloud interprets it when a private key and password are both supplied - for example, the password could either be needed for decrypting the private key, or it could be required by the remote system in addition to having the private key.

Thanks!
My problem is that I cannot open the settings from the GUI. So I am not sure what has gone wrong there . . .

I just wanted to say that there is another user with this problem, but it’s you:

Did you upgrade to php 8.0 recently or was it already working with php 8.0 and NC 20? In case of a new php 8.0, I’d check if all the required modules were installed: https://docs.nextcloud.com/server/21/admin_manual/installation/source_installation.html

If you set up new external storage, does it work then?

Since the return of a function is not handled correclty, I’d suggest to create a bug report on Issues · nextcloud/server · GitHub

What is bothering me a bit, if it is a bug, why didn’t anyone else report it yet? External storage + php 8 doesn’t look very specific…

I have checked and seem to have all the required php modules.
Before reporting a potential bug I’d like to make sure something specific to my install / situation isn’t overlooked.
I guess the logging I’ve report is the most relevant to the error?