ParrotSecurity 4.2: sudoでパスワード入力を不要にする


Table of Contents

1 sudoでパスワード入力を不要にする

visudoで/etc/sudoersを編集します。この時点ではまだパスワードが必要です。

$ sudo visudo[sudo] password for hiroom2:

sudoグループのところを以下のように変更します。

$ sudo diff -uprN /etc/sudoers.orig /etc/sudoers— /etc/sudoers.orig 2017-06-19 00:41:29.421047745 +0900+++ /etc/sudoers 2017-06-19 00:41:41.481044752 +0900@@ -20,7 +20,7 @@ Defaults secure_path=”/usr/local/sbin:/u root ALL=(ALL:ALL) ALL # Allow members of group sudo to execute any command-%sudo ALL=(ALL:ALL) ALL+%sudo ALL=(ALL:ALL) NOPASSWD:ALL # See sudoers(5) for more information on “#include” directives:

これ以降はsudoでパスワード入力が不要となります。

2 sudoでリダイレクトを扱う

パスワード入力とは離れますが、スクリプトでの操作自動化で必要になる場合があるので記載します。

以下のようにcommandはsudoで実行されますが、リダイレクトの>はsudoで実行されない為、/etc/fileに書き込めません。

$ sudo command > /etc/file

sudo su -cを用いてrootでcommandとリダイレクトを実行します。

$ sudo su -c ‘command > /etc/file’

あるいはteeコマンドを用います。

$ sudo command | sudo tee /etc/file

Android | Linux | SDL - Narrow Escape