[Solved] How suspend remotely or without sudo?

Issues related to applications and software problems and general support
Post Reply
m0t0m
Posts: 22
Joined: 2017/01/04 10:05:56

[Solved] How suspend remotely or without sudo?

Post by m0t0m » 2020/09/28 10:14:29

I want to be able to suspend my CentOS 8.2 remotely.

Currently I log in with ssh and run

Code: Select all

$ sudo systemctl suspend 
However instead I want to be able to send command with

Code: Select all

$ ssh $MACHINE "systemctl suspend" &
 % Failed to set wall message, ignoring: Interactive authentication required.
Failed to suspend system via logind: Interactive authentication required.
Failed to start suspend.target: Interactive authentication required.
See system logs and 'systemctl status suspend.target' for details.
Either how do I disable suspend to require a password or is there a smarter way to do it?
Last edited by m0t0m on 2020/10/12 16:01:33, edited 1 time in total.

m0t0m
Posts: 22
Joined: 2017/01/04 10:05:56

Re: How suspend remotely or without sudo?

Post by m0t0m » 2020/10/12 16:01:22

Maybe not the safest way, but I added my ssh access to root and just send the command via the root user

Code: Select all

$ ssh root@machine "systemctl suspend" &

User avatar
TrevorH
Forum Moderator
Posts: 29719
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: [Solved] How suspend remotely or without sudo?

Post by TrevorH » 2020/10/12 16:18:20

Part of the problem is that you neglected to use sudo when you did it via ssh or if you did then you omitted it from the command you quoted here. If you do use sudo via ssh then you probably either need to use ssh -t or tell sudo that a tty is not required (e.g. Defaults:m0t0m !requiretty)
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

m0t0m
Posts: 22
Joined: 2017/01/04 10:05:56

Re: [Solved] How suspend remotely or without sudo?

Post by m0t0m » 2020/10/12 16:38:12

Switching to my sudo user requires a password, so I don't see how -t or tty is not required would fix the issue.

User avatar
TrevorH
Forum Moderator
Posts: 29719
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: [Solved] How suspend remotely or without sudo?

Post by TrevorH » 2020/10/12 20:00:00

So make it sudo that command without password.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

m0t0m
Posts: 22
Joined: 2017/01/04 10:05:56

Re: [Solved] How suspend remotely or without sudo?

Post by m0t0m » 2020/10/13 07:59:07

Yes that would work.
I ended up using ProxyJump so only my local machine has the root ssh key.

Code: Select all

Host raspberryPI
    HostName $PUBLIC_IP 
    User $USER
    port $OTHER_THAN_22

Host root-server
    HostName $LOCAL_IP 
    User root
    port 22
    ProxyJump raspberryPI

Post Reply

Return to “CentOS 8 - General Support”