Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

542
Vistas
CENTOS apache ALL=(root) NOPASSWD: /path/to/shell.sh is not working

I am trying to do a web interface by IPtables management.

I created a file, whose name is test.php

$output = shell_exec('bash /usr/bin/iptables.sh 2>&1');
echo $output;

I gave /usr/bin/iptables.sh NOPASSWD so I could execute the file with sudo through apache without using a password

sudo iptables -L

sudoers file :

apache ALL=(root) NOPASSWD: /usr/bin/iptables.sh

But I am still getting the following error:

We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper{"mode":"full","isActive":false}

However, if I use

apache ALL=(root) NOPASSWD: ALL

Everything works fine.

I double-checked my directory and I used the exact path

[root@CentOS bin]# readlink -f iptables.sh
/usr/bin/iptables.sh

Super clueless here, can anyone help me with a direction? :'(

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This has been solved.

The answer is here if someone has the same issue

https://serverfault.com/questions/1070602/centos-apache-all-root-nopasswd-path-to-shell-sh-is-not-working/

bash is redundant

Just remove the bash and run like this instead

$output = shell_exec('/usr/bin/iptables.sh 2>&1');
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda