LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-08-2024, 02:24 PM   #1
charliegreen
LQ Newbie
 
Registered: Jan 2024
Posts: 4

Rep: Reputation: 0
Does a new user for running systemd service need a password?


I'm setting up a backend service using nginx + gunicorn and I want to run the gunicorn part as a service automatically using systemd but I want to create a separate user and group for that so it's not running with root privilege.

Anyway when I run the command sudo adduser backend it didn't present me with any prompts, it just created the user with defaults. It also didn't ask me to specify a password. These are the defaults

Code:
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
I found that group 100 is the 'users' group. But I will change that and create a new group with the same name 'backend'.

My systemd service file looks similar to this

Code:
[Unit]
Description=Gunicorn instance to serve application
After=network.target

[Service]
User=backend
Group=backend
WorkingDirectory=/path/to/your/app
Environment="PATH=/path/to/venv/bin"
ExecStart=/path/to/venv/bin/gunicorn --workers 3 --bind 0.0.0.0:5003 web_dynamic.2-hbnb:app
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
PrivateTmp=true

[Install]
WantedBy=multi-user.target
I noticed there is no password specified in all the examples I looked at for the systemd service file. What do I do about the password, do I give the new user a password, or create it without one? And how does the service work without entering a password?

Last edited by charliegreen; 02-08-2024 at 06:44 PM.
 
Old 02-08-2024, 07:49 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,328
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
I don't know enough to answer your question, but I think you may find this article helpful. It has a section specifically about permissions.
 
Old 02-14-2024, 05:29 AM   #3
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
'adduser' is often a distro specific convenience frontend script for creating "normal" interactive users. For system users such as you are creating you really want to use the underlying groupadd and useradd commands.

In general "system" users like this typically don't have a password set but a common practice for "system accounts" is the set the password field to 'x' (which will never match a supplied password), So, assuming UID/GID 500 is free:
groupadd -g 500 backend
useradd -r -p x -u 500 -g backend -C "system account for gunicorn" backend


I wouldn't expect systemd to have a problem with a user setup this way, but I'm not much of a systemd guy.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to Deploy Flask Application with Nginx and Gunicorn on Ubuntu 20.04 LXer Syndicated Linux News 0 02-26-2022 04:54 AM
LXer: How to Setup Django with Postgres, Nginx and Gunicorn on Ubuntu 20.04 LXer Syndicated Linux News 0 02-09-2022 10:30 PM
LXer: Hosting Django With Nginx and Gunicorn on Linux LXer Syndicated Linux News 0 02-07-2017 09:00 AM
Missing package when trying to build server (gunicorn) chris_crunch Linux - Newbie 5 02-05-2016 08:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration