Not knowing if this is a client or Nextcloud installation problem, but suspecting the latter, I have posted here
I am setting up the Nextcloud Ubuntu Appliance on my RPi3 Nextcloud Box which has an external hard disk.
I have my data on the RPi external disk (I connected it to my PC and copied it over then scanned using
sudo nextcloud.occ files:scan when back on the RPi) and I can access the files on the external disk via nextcloud.local
I then synced with the data on my Manjaro OS PC using the client (version 3.03 (Manjaro)), but if I put a new file on the PC the client returns an error 403 Forbidden to PUT … (Sabre\DAV\Exception\Forbidden) and the file is not transferred (although the client gives me a tick to say all synced correctly)
I have already, via ssh, run
sudo snap connect nextcloud:removable-media core:removable-media which I thought would give the Snap permissions, and I can access the files on the external disk via nextcloud.local
Syncing between my PC and a folder on the RPi SD card itself works no problems, so I guess its some problem with the permissions of the external hard disk on the RPi
I automatically mount the external disk as per here
Any ideas, please?
Can you confirm that you’re able to upload/edit new files on external storage using the web interface?
Using the web interface (for the external disk):
- I can download
- I can open a txt file and make changes.
- I can not upload (Forbidden)
- I can not make a new file or folder (could not create …)
The above is true within the main folders that I copied to my RPI hard disk from my PC
However, if I move to the ‘root directory’ of the external disk in the Web interface I can upload and make new files and folders
try this : sudo chown -R www-data:www-data /path-of-your-external-storage
if it not resolve the issue try : sudo chmod -R 750 /path-of-your-external-storage
Before I read your post, I had just looked at the permissions:
(i) Disk root:
drwxrwxrwx 6 leigh root
(ii) Both main folders on Disk:
drwxr-xr-x 22 leigh leigh
Since it worked for the disk root (permissions 777) but not the main folders (permissions 755) I simply ran
sudo chmod -R 777 for both folders, and it all worked
However, I was just about to post asking if my setting full rights to everyone was a dumb thing to do (even though I am the only one using it)
Now I have seen your post I think maybe yes it was dumb
So, to do what you suggested, for both folders I did:
sudo chown -R www-data:www-data /path-of-each-external-folder-in-turn
sudo chmod -R 750 Disk/path-of-external-storage
But like that I couldn’t write to the folders on the disk again, and additionally not even to the root of the disk (as I could before)
So, I tried changing the ownerships back to what they were (as in (i) & (ii) above) but still no luck
Then I changed back to permissions 777, and now I can make new folders and files again on all parts of the external disk
But is this a good way to make it work?
I havent started the client sync before I am happy that I know what is going on.
Nextcloud is running as (confined) root, not www-data, so @Mageunic’s suggestion is better written as:
$ sudo chown -R root:root /path-of-storage
Despite your being the only user here, it’s best practice to not use 777 for permissions unless you explicitly desire that functionality. I suspect you need no more than 700 for directories and 600 for files, but 750 across the board is probably okay.
Thanks @kyrofa ,
I was just looking at the permissions of files that I upload from the web interface and they are all root:root.
When I restart the client, will it now attempt to change the permissions of all my files on the laptop, or are permissions only local?
i.e. is it best for me to start again from scratch? (not the end of the world)
Also, I will set up again access from the outside world, 750 OK for that?
Yeah that’s a good way to figure that stuff out.
Oh no, that’s only on your server, don’t worry. The files will continue to be owned by the user running the client.
Heavens no, you’re so close! Although I applaud your attitude .
750 is fine.
Its the bumbling along, not really knowing what I’m doing but learning along the way that I find most fun, that’s why doing it all again is no problem
sudo chown -R root:root /media/usb &
sudo chmod -R 750 /media/usb/ gave me access to the files, the client would not sync and Nextcloud repeatedly stopped so I redid the transfer of the files to my external disk etc:
- Deleted the external disk ‘external storage’ on the Web Interface
- Deleted the Folder Sync connections in the Client
- Physically connected the external disk to my laptop with a USB cable,
- Deleted my files from the external disk,
- Re-transferred my files over to the external disk from my laptop NB making sure to use
cp -rp so that then the desktop client worked properly and didn’t flag up false changes
sudo nextcloud.occ files:scan --path="<Nextcloud user_id>/files/<name given to disk in Nextcloud>/<Directory of interest on external disk>"
sudo chown -R root:root /media/usb
- Re-added the external disk as an external storage
- Re-added the Folder Sync connections in the Client
And now everything is working fine (fingers crossed!)
[ I did not need to run
sudo chmod -R 750 /media/usb/]