ubuntu重启&;带密码的关机命令
我正在用Java编写一个程序来关闭Ubuntu服务器ubuntu重启&;带密码的关机命令,ubuntu,ssh,sudo,shutdown,reboot,Ubuntu,Ssh,Sudo,Shutdown,Reboot,我正在用Java编写一个程序来关闭Ubuntu服务器 echo password | sudo -S shutdown -h now sudo -p 'password' shutdown -h now 两个命令都不起作用 我需要sudo命令关闭并通过传递密码重新启动我的服务器。 因为我是从程序中执行此操作的,所以它不应该提示输入密码。密码也应随命令一起发送。任何建议都会很有帮助。…sudo的-p选项指定提示,而不是密码。看看-a选项。sudo手册页摘录-: -A No
echo password | sudo -S shutdown -h now
sudo -p 'password' shutdown -h now
两个命令都不起作用
我需要sudo命令关闭并通过传递密码重新启动我的服务器。
因为我是从程序中执行此操作的,所以它不应该提示输入密码。密码也应随命令一起发送。任何建议都会很有帮助。…sudo的-p选项指定提示,而不是密码。看看-a选项。sudo手册页摘录-:
-A Normally, if sudo requires a password, it will read it from the current
terminal. If the -A (askpass) option is specified, a
helper program is executed to read the user's password and output the
password to the standard output. If the SUDO_ASKPASS environment variable
is set, it specifies the path to the helper program. Otherwise, the value
specified by the askpass option in sudoers(5) is used.
助手程序必须输出正确的密码。因此,要指定帮助程序-:
export SUDO_ASKPASS="/path/to/helper"