Access to the server files with the user www-data

Hello!!!
Here my problem: I have Nextloud (by Docker) on a Raspberry Pi, working correctly. The data files on the server are owned by www-data and I need to access the files via SSH, SAMBA, or PLEX to make Backups or read them with Plex.
I don’t know the password of www-data to be able to log in with SSH or with SAMBA.
Maybe there is a better way to access the files, but I would not like to play with the permissions as I am assuming that nextcloud sets them appropriately.
Thanks a lot!!!

Hi @carlos

You can do it…

https://askubuntu.com/questions/702060/how-to-give-permissions-to-www-data-to-log-in-with-ssh

…but YOU REALLY SHOULD NOT!

https://ubuntuforums.org/showthread.php?t=2280551

If you want to a access the files via Samba or other services you could create a separate user/group and set the ownership of the folder correctly. But I wouldn’t even do that. It only makes things more complicated and thus potentially less secure. Personally, I would manage the media folders for Plex completely independently. I mean you have Plex, which is much better suited for media playback than Nextcloud anyways. And if you still want to access the media files within Nextcloud, you could include them with the External Storage App.

As for backup… If you don’t want to initiate the backup on the server for whatever reason, but want to “pull” it from outside. You could create a separate user for this purpose, who is a member of the www-data group. This user should only be able to log in with an SSH key and should have limited shell access and certainly no sudo rights.

1 Like

Thank you very much bb77, I think I have understood you.

1.- Then I will not modify the properties of www-data and I will let Nextcloud manage the server without interference.

2.- In this case, how can I make backups of my photos that Nextcloud has uploaded from my smartphone?

3.- About Plex access, I have not understood you as would be the correct way to access my photos and videos (those that have been uploaded from my smartphone) located on the server, because I do not want to synchronize these with another disk ( which you could access with plex) so as not to duplicate files.

That depends on your infrastructure.

  • Where are the files respective ist the Nextcloud data folder located? (e.g. on the same server as Nextcloud or on a NAS?)
  • Do you want to backup only the files or the complete Nextcloud installation?
  • Where should the files be backed up to? (e.g. USB disk, NAS, offsite/cloud backup)

If you only want to backup the files, e.g. to a NAS inside your local network, you could use rsync in combination with a cronjob. Rsync also works over SSH. So you don’t need a Samba share.

If Plex is running on the same server, I guess you could add the Plex user to the www-data group or www-data to the Plex group. From a security point of view, this is probably not quite optimal, but it should work. I run Plex and Nextcloud completely separate. They are not even in the same network segment. I also don’t use Plex for personal cell phone videos and photos. Plex only has read access to my media library, which is stored on my NAS.

I have a Raspi 4 with Raspbian Buster, Openmediavault and an external hard disc connected by USB.
Nextcloud is running by Doker on Raspi 4 and using the disk to store Nextcloud data.

I want to store the backup copies on another hard disk also connected to the Raspi 4 via USB.
I am accessing both hard drives through SAMBA, from my PC which is on the same network.

Thank you bb7.
I also use Plex with docker, so the Plex user does not exist on the server (the same server runs Nextcloud and Plex), on the contrary, the user that I am calling in the docker-compose so that Plex can access my data is pi (I do this in the docker-compose, where PUID = 1000 and PGID = 100).