I have a script file on a debian server machine that uses /sbin/iptables to ban ips that are trying to enter to my system. I had the script as a crontab entry but I've realised that it wasn't working as expected because it needed to be a root user.
Whenever I run the script as sudo myscript the the script works as expected. If I don't use sudo it gives me:
iptables v1.4.21: can't initialize iptables table `filter': Permission denied (you must be root) Perhaps iptables or your kernel needs to be upgraded
If I type "id" I get:
uid=1000(username) gid=33(www-data) groups=33(www-data),0(root),27(sudo),1001(developers)
www-data sudo developers
So it seems that the user is inside the sudo group, however it doesn't have access to the iptables command, i.e. if I type as "username" iptalbes it tells me command not found.
Furthermore, I was reading about the /etc/sudoers that you can give access to specific users. I've changed from 440 to 740 the permission rights and I uncommented
# Allow members of group sudo to execute any command sudo ALL=(ALL:ALL) ALL
Now everytime I type sudo whatever command I get
username is not in the sudoers file. This incident will be reported.
Some help would be appreciated..