作業ログ:sudo のインストール
私のサーバ管理のポリシーとして、作業は基本的に作業用の worker ユーザ で行う。そして、root 権限が必要な操作は sudo を利用する。
インストール
lv1:~# aptitude install sudo Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done Reading task descriptions... Done The following NEW packages will be installed: sudo 0 packages upgraded, 1 newly installed, 0 to remove and 12 not upgraded.
設定
以下のように設定します。
- sudo グループに属するユーザはパスワードを入力すれば root 権限で任意のコマンドを実行できる。
- worker ユーザを sudo グループに追加する。
このように設定している場合、worker ユーザを乗っ取られるとなんでもできてしまう。
SSH でパスワード認証を無効にしているので、よっぽどのことがない限り問題ないと思うんだけど、他の人はなんかしているのかな。
lv1:~# sed -i.orig 's|# %sudo ALL=NOPASSWD: ALL|%sudo ALL=(ALL) ALL|' /etc/sudoers lv1:~# diff -u /etc/sudoers.orig /etc/sudoers --- /etc/sudoers.orig 2008-08-09 22:16:40.893009889 +0900 +++ /etc/sudoers 2008-08-09 22:38:32.042667735 +0900 @@ -19,4 +19,4 @@ # Uncomment to allow members of group sudo to not need a password # (Note that later entries override this, so you might need to move # it further down) -# %sudo ALL=NOPASSWD: ALL +%sudo ALL=(ALL) ALL lv1:~# adduser worker sudo Adding user `worker' to group `sudo' ... Adding user worker to group sudo Done.
動作確認をします。
worker@lv1:~$ sudo -v 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] password for worker: worker@lv1:~$ sudo ls worker@lv1:~$ sudo -k worker@lv1:~$ sudo -v [sudo] password for worker: worker@lv1:~$
メモ
これまで Debian GNU/Linux sarge や etch では作業用のユーザを追加するグループは staff にしていました。
しかし、今回の lenny での sudo の設定では sudo グループにしました。これは、lenny の sudoers に「# %sudo ALL=NOPASSWD: ALL」という記述があったからです。
lenny では sudo グループに追加するのを想定しているのでしょうかね。