IPTABLESとsudoersファイルの問題

IPTABLESとsudoersファイルの問題

私のシステムに入ろうとするIPを禁止するために/ sbin / iptablesを使用するDebianサーバーシステムにスクリプトファイルがあります。スクリプトをcrontabエントリとして使用しましたが、root権限が必要なため、期待どおりに機能しないことに気づきました。

sudo myscriptでスクリプトを実行するたびに、スクリプトは期待どおりに機能します。 sudo を使用しない場合は、以下が提供されます。

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

「id」と入力すると、次のようになります。

uid=1000(username) gid=33(www-data) groups=33(www-data),0(root),27(sudo),1001(developers)

とグループ

www-data sudo developers

したがって、ユーザーがsudoグループ内にあるように見えますが、iptablesコマンドにアクセスできません。つまり、「username」iptalbesと入力すると、そのコマンドが見つからないというメッセージが表示されます。

また、特定のユーザーにアクセス権を付与できる/etc/sudoersについても読んでいます。権限を440から740に変更し、コメントを削除しました。

# Allow members of group sudo to execute any command
sudo    ALL=(ALL:ALL) ALL

どのコマンドを受け取ってもsudoを入力するたびに

username is not in the sudoers file.  This incident will be reported.

少し助けてくれてありがとう。

ありがとう

ベストアンサー1

おすすめ記事