Adding external storage in Nextcloud fails with “wrong password”

If you are having trouble with adding external storage mounts in Nextcloud, you can do this:

$ sudo -u www-data php occ files_external:list

You can see the bad external mounts and delete it with:

$ sudo -u www-data php occ files_external:delete X

Then, you can re-create good ones by using this command:

$ sudo -u www-data php occ files_external:create Blabla ‘smb’ password::password -c host=X.X.X.X -c share=X -c root=/X -c domain=workgroup -c user=X -c password=X

You can add applicable users to the mount using this command:

$ sudo -u www-data php occ files_external:applicable --add-user=X

Replace: X with Yours.

Reference

https://help.nextcloud.com/t/add-external-storage-failed-at-action-needs-authentication-failed-wrong-password/213089/6