Article 5KQ7H Running a systemd service as a non-root user

Running a systemd service as a non-root user

by
taylorkh
from LinuxQuestions.org on (#5KQ7H)
I have need to run this service as a non-root user. I modified my service file from the one I previously ran as root and placed it in ~/.config/systemd/user/Code:ken@vmMintVPN:~/.config/systemd/user$ cat protonvpn.service
[Unit]
Description=Connect to ProtonVPN
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=ken
ExecStart=/usr/local/bin/protonvpn3.sh

[Install]
WantedBy=multi-user.targetI then ranCode:ken@vmMintVPN:~/.config/systemd/user$ systemctl --user daemon-reload
ken@vmMintVPN:~/.config/systemd/user$ systemctl --user list-unit-files protonvpn.service
UNIT FILE STATE VENDOR PRESET
protonvpn.service disabled enabled

1 unit files listed.

ken@vmMintVPN:~/.config/systemd/user$ systemctl --user enable --now protonvpn.serviceWhen I checked the statusCode:ken@vmMintVPN:~/.config/systemd/user$ systemctl --user status protonvpn.service
protonvpn.service - Connect to ProtonVPN
Loaded: loaded (/home/ken/.config/systemd/user/protonvpn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2021-06-30 09:13:01 CDT; 5min ago
Process: 25686 ExecStart=/usr/local/bin/protonvpn3.sh (code=exited, status=216/GROUP)
Main PID: 25686 (code=exited, status=216/GROUP)

Jun 30 09:13:01 vmMintVPN systemd[1069]: Started Connect to ProtonVPN.
Jun 30 09:13:01 vmMintVPN systemd[25686]: protonvpn.service: Failed to determine supplementary groups: Operation not permitted
Jun 30 09:13:01 vmMintVPN systemd[25686]: protonvpn.service: Failed at step GROUP spawning /usr/local/bin/protonvpn3.sh: Operation not permitted
Jun 30 09:13:01 vmMintVPN systemd[1069]: protonvpn.service: Main process exited, code=exited, status=216/GROUP
Jun 30 09:13:01 vmMintVPN systemd[1069]: protonvpn.service: Failed with result 'exit-code'.I have no idea what the "group" is. The bash script /usr/local/bin/protonvpn3.sh functions correctly if I run it manually.

Can anyone offer any suggestions?

TIA,

Kenlatest?d=yIl2AUoC8zA latest?i=hu2lPRgtPtw:EnOOjNvKTTI:F7zBnMy latest?i=hu2lPRgtPtw:EnOOjNvKTTI:V_sGLiP latest?d=qj6IDK7rITs latest?i=hu2lPRgtPtw:EnOOjNvKTTI:gIN9vFwhu2lPRgtPtw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments