ubuntu server 18.04的ssh普通用户如何在脚本中关机、重启
发表于 : 2018-11-04 21:16
ubuntu server 18.04,普通用户通过ssh,可以sudo后执行reboot,poweroff,但不sudo不行,如
userrer@hserver:~$ poweroff
Failed to set wall message, ignoring: Interactive authentication required.
Failed to power off system via logind: Interactive authentication required.
Failed to open /dev/initctl: Permission denied
Failed to talk to init daemon.
userr@hserver:~$ reboot
Failed to set wall message, ignoring: Interactive authentication required.
Failed to reboot system via logind: Interactive authentication required.
Failed to open /dev/initctl: Permission denied
Failed to talk to init daemon.
如果在本地登录,则poweroff和reboot都可以直接使用。
目前在ssh登录后,用sudo来关机,重启
但现在要想放在一个脚本中,又不想用root,有什么办法?
userrer@hserver:~$ poweroff
Failed to set wall message, ignoring: Interactive authentication required.
Failed to power off system via logind: Interactive authentication required.
Failed to open /dev/initctl: Permission denied
Failed to talk to init daemon.
userr@hserver:~$ reboot
Failed to set wall message, ignoring: Interactive authentication required.
Failed to reboot system via logind: Interactive authentication required.
Failed to open /dev/initctl: Permission denied
Failed to talk to init daemon.
如果在本地登录,则poweroff和reboot都可以直接使用。
目前在ssh登录后,用sudo来关机,重启
但现在要想放在一个脚本中,又不想用root,有什么办法?