【问题标题】:Bash script via php (apache2)通过 php (apache2) 的 Bash 脚本
【发布时间】:2018-11-12 00:41:49
【问题描述】:

Bonsoir,我有一个在终端上正常运行的 bash 脚本,但是当我通过 php 运行它时,它会运行一些命令(那些没有 sudo 的命令)。 这是我授予 www-data 权限的文件 sudoers:

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
www-data ALL=(ALL:ALL) NOPASSWD:ALL

当我输入 sudo service apache2 status 时出现这个错误:

juin 01 21:33:13 les-tatates-cm sudo[21697]: pam_unix(sudo:auth): auth could not identify password for [www-data]

如何解决?需要帮助!

【问题讨论】:

  • 试试NOPASSWD: SERVICES
  • 总是同样的错误@UlyssesMarx!
  • 你用的是什么操作系统?
  • 我使用的是 linux,Ubuntu 16.04.4
  • 当用户实际上仍然有密码检查 /etc/passwd 时会发生这种情况

标签: php bash apache2 sudoers


【解决方案1】:

你可以这样做:

<?php
include('Net/SSH2.php');

$ssh = new Net_SSH2('www.domain.tld');
$ssh->login('username', 'password');

$ssh->read('[prompt]');
$ssh->write("sudo command\n");
$ssh->read('Password:');
$ssh->write("Password\n");
echo $ssh->read('[prompt]');
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-22
    • 2018-03-29
    • 2022-01-20
    • 1970-01-01
    相关资源
    最近更新 更多