S
S
Serg4452019-10-23 09:57:35
linux
Serg445, 2019-10-23 09:57:35

How to create a user on a remote Ubuntu server and restart the service from under it remotely?

Good afternoon !
There are 2 servers with ubuntu, you need to create a non-privileged user from under which to restart the nginx service.
I did this: I
created a user: useradd -ppass -m -s /bin/bash restart
created a file in sudoers.d\restart
with the following content:
restart ALL=NOPASSWD: /bin/systemctl restart nginx
In sshd_config added
AllowUsers restart root
rebooted the sshd service
After that I try to reboot from the server with the command:
systemctl --host [email protected] restart nginx
I get:

Failed to restart nginx.service: Interactive authentication required.

at the same time, if I do
systemctl --host [email protected] status nginx
that, I get the status of the service and everything is fine.
Tell me what am I doing wrong?
where am i wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Shitskov, 2019-10-23
@Zarom

It looks like you can't do without an explicit ssh call with sudo
https://unix.stackexchange.com/questions/466006/re...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question