[solved] poweroff over ssh

6 posts / 0 new
Last post
#1 Sat, 2015-12-05 10:42
ronnysc
  • ronnysc's picture
  • Offline
  • Last seen: 2 years 3 months ago
  • Joined: 2015-12-05

Hello,
is it possible to shut down the alpine system with "poweroff" over ssh? i haven't found a solution for it. As "root" working "poweroff" but not as user Login. But i don`t want to log in as "root" over ssh.
The Server isn't on the Internet only into my home net.

Best regards
Ronny

Sat, 2015-12-05 11:23
p180
  • p180's picture
  • Offline
  • Last seen: 2 years 2 months ago
  • Joined: 2015-12-05

You can use "sudo" for such actions ;-)

Sat, 2015-12-05 12:21 (Reply to #2)
ronnysc
  • ronnysc's picture
  • Offline
  • Last seen: 2 years 3 months ago
  • Joined: 2015-12-05

 ssh -p 22 -i ~/.ssh/id_rsa user@alpine-server 'sudo poweroff'
is it correct?

Sat, 2015-12-05 13:03 (Reply to #3)
p180
  • p180's picture
  • Offline
  • Last seen: 2 years 2 months ago
  • Joined: 2015-12-05

Yes, it should work. But you have to configure your sudoers file that you can use it without a password prompt.

Sat, 2015-12-05 15:01 (Reply to #4)
ronnysc
  • ronnysc's picture
  • Offline
  • Last seen: 2 years 3 months ago
  • Joined: 2015-12-05

Thanks. I'l try it next week. Now it's weekend ;).

Mon, 2015-12-07 21:08 (Reply to #5)
ronnysc
  • ronnysc's picture
  • Offline
  • Last seen: 2 years 3 months ago
  • Joined: 2015-12-05

Yes, it's working... I'm so happy.

What have i do:
1. edit the file sudoes
 visudo
and insert 2 Lines:
 Cmnd_Alias = SHUTDOWN_CMD = /sbin/poweroff
 <your name> ALL=(ALL) NOPASSWD: SHUTDOWN_CMD
for "your name" insert the real name
2.  ssh -p 22 -i ~/.ssh/id_rsa user@alpine-server 'sudo poweroff'
and the server shuts down... perfect

thanks
Ronny

Log in or register to post comments