Ssh:d to a raspberry pi with Raspbian 11 I'm trying to create a userspace systemd service unit and timer for running an rsync command that would sync two folders under the home folder of the user I'm logged in as. (The .service is at ~/.config/systemd/user/ and enabled via systemctl --user enable (service file name). If I run the rsync command (as the logged in user and without sudo) everything is OK. When I attempt to run the mentioned service (systemctl --user start (service name ) I get rsync: [sender] opendir "/home/theuser/samba/projfolder/afolder" failed: Permission denied (13) and the same for every subfolder in the projfolder folder (as well as a hidden file in the projfolder).

The permissions of one of these subfolders is : drwxrws--- 2 sambaservant servantgroup where 'sambaservant' is a local user tied to a samba user responsible for the samba share that I'm trying to copy. The user I am logged in with is a member of the "servantgroup" (hence why I can read and rsync said folder I think) as is the sambaservant.

The rsync command I'm trying to run is rsync -av /home/theuser/samba/projfolder/ /home/theuser/local_backup_copies/

The service is:

Description=Sync Samba share proj folder to other folder

ExecStart=rsync -av /home/theuser/samba/projfolder/ /home/theuser/local_backup_copies/

The rsync command succeeds as a service if the source directory and its contents are owned by the user I'm logged in as (as opposed to the directory I'm trying to copy from currently).

How can the rsync command succeed when I run it manually (as the logged in user) and fail when run via a systemd user space service?

  • Can you show findmnt -u /home/theuser/samba? What groups are you in (according to id with no parameters) when logged in normally, and what groups is your systemd --user manager in according to systemd-run --user -qPG /bin/id? Commented Apr 30, 2023 at 11:47
  • findmnt -u /home/theuser/samba outputs nothing, systemd-run --user -qPG /bin/id outputs Failed to connect to bus: No such file or directory, id outputs groups=1000(theuser),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),104(input),106(render),108(netdev),997(gpio),998(i2c),999(spi),1002(servantgroup). (This is logged in with theuser via ssh, by "normally" did you perhaps mean "locally"? It's a headless Pi but I can connect a display and mouse and keyboard to it
    – piggvar
    Commented Apr 30, 2023 at 13:27
  • Do SSH sessions show up in loginctl on Raspbian? (Generally they should.) Does it still have the "dbus-user-session" package as a separate thing? (It contains the components that start dbus.service and allow systemd-run to work.) Was the Samba share mounted at the time you ran findmnt? Commented Apr 30, 2023 at 13:43
  • Yes, they do show up it seems. And "dbus-user-session" was an available not-installed package which I installed and after a reboot systemd-run --user -qPG /usr/bin/id reports: uid=1000(theuser) gid=1000(theuser) groups=1000(theuser),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),104(input),106(render),108(netdev),997(gpio),998(i2c),999(spi),1002(servantgroup) . Yes, the samba/projfolder was mounted, on the same system as I am ssh:ing from. That is to say the Pi is acting as a samba server.
    – piggvar
    Commented Apr 30, 2023 at 14:16
  • Ah, so the service is running on the SMB server, not on the client? Commented Apr 30, 2023 at 14:17

1 Answer 1


I ran into the exact same problem, but I don't have a solution, thought, I can answer this part from previous SystemD experiences:

How can the rsync command succeed when I run it manually (as the logged in user) and fail when run via a systemd user space service?

SystemD, in LP's infinite decided to do cgroups/resource-containments/capability-limitations/etc.etc./etc.

The question that should be asked: How to turn off those problems

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .