
私はサードパーティのインストーラースクリプト(ansible tower setup.sh)を実行しようとしていますが、一部のコマンドはroot権限を必要とするため、rootとしてまたはsudo経由で起動する必要があります。しかし、スクリプト実行中のコマンドはsudoを試みる理由は聞かないでください。セットアップ スクリプトは、いくつかの矛盾を伴う共同作業だと思います...
スクリプトは失敗し、再現することができます。rootとしてsudoを実行しようとすると、いつもこの奇妙なエラーが発生します。
root@machine:/home/someuser: sudo echo 1
root is not allowed to run sudo on <FQDN here>. This incident will be reported.
これまでの Ubuntu の経験では、このようなことは一度も見たことがありません (公平を期すために言うと、現在 Google でも見たことがありません)。
すべての場所を見つけてスクリプトを変換して sudo を呼び出さないようにするオプションはないため、ルート ユーザーが sudo を実行できるようにする方法を見つける必要があります。私が作業している Ubuntu 16.04 サーバーは、会社のプライベート クラウド プロバイダーによってドメイン内で特殊な方法で構成されています (これが重要かどうかはわかりません)。
私の /etc/sudoers は次のようになります:
#
# This file MUST be edited with the 'visudo' command as root.
# more bla bla
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
+unixadmin,+unixadminext ALL= NOPASSWD: ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
sudoについて:
root@machine:/home/someuser# which sudo
/usr/bin/sudo
root@machine:/home/someuser# ll /usr/bin/sudo
-rwsr-xr-x 1 root root 140816 Jun 7 2017 /usr/bin/sudo*
何が足りないのでしょうか?
sudo グループに root ユーザーを追加しましたが、問題は解決しませんでした。
答え1
root として実行しますgroups
- root は sudo グループに属していません。なぜ属する必要があるのでしょうか?
これを修正する方法としては、sudo グループに root を追加するか、sudo を実行するスクリプトにチェックを入れることができます (これは特定の問題に対する可能性としては除外していますが、他の問題に対する解決策になるかもしれません)。
sudo グループに root を追加するには:
(ルートとして)usermod -a -G sudo root