0
0

More than 3 years have passed since last update.

sudoでパスワード入力を省略する

Posted at

sudoでパスワードを入力しない方法

背景

  • sudo を行うたびにパスワードを入力するのが煩わしいので、パスワードを入力しないようにしたい。参考の方が詳しいのであえて書く必要はなかったかもしれないが、自分の気づきもあったので書いてみた。

環境

  • Ubuntu 18.04.5(LTS)

解説

  • sudoers ファイルにパスワード入力しなくても良い設定を記載すればよい。
  • ただし、viやnanoでファイルを編集するのは危険なので、visudoを使用する。
  • また、今回の方法はすべてのコマンドでパスワードを入力しなくなるので、若干、危険である。 気になる場合は、パスワードを入力しないコマンドを指定することもできるらしい。

手順

  1. sudoersファイルを開く

    $sudo visudo

  2. Allow members of group sudo to execute any commandの後に設定を追加する。(場所が大事!)

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
user-name ALL=(ALL) NOPASSWD:ALL ##追加!

参考

https://phpraxis.wordpress.com/2016/09/27/enable-sudo-without-password-in-ubuntudebian/
https://qiita.com/RyodoTanaka/items/e9b15d579d17651650b7

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0