LoginSignup
20
17

More than 3 years have passed since last update.

is not in the sudoers file.This incident will be reported.となった時の対応方法

Last updated at Posted at 2020-05-04
メッセージ
(英語版)
{ユーザー} is not in the sudoers file.  This incident will be reported.
(日本語版)
{ユーザー} は sudoers ファイル内にありません。この事象は記録・報告されます。

事象 : ユーザーを作ってsudoしたらなんか言われた

  • 環境 : CentOS Linux release 7.8.2003 (Core)

設定したパスワードを入れてもダメだった・・・

$ sudo chmod 700 ~/.ssh/id_rsa

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 ponsuke:
ponsuke is not in the sudoers file.  This incident will be reported.

ユーザーがsudoできるグループにいないから

/etc/sudoers ファイルには、あらかじめsudoコマンドを利用できるグループが用意されています。Debianの場合は、sudoグループ。CentOSの場合はwheelグループ。
sudoユーザーを追加する方法 - Linux入門 - Webkaru

wheelグループにいなかった
$ cat /etc/group | grep wheel
wheel:x:10:centos

対応 : wheelグループにユーザーを追加する

  1. sudoを実行できるユーザーに切り替える
  2. usermodwheelグループにユーザーを追加する
  3. ユーザーを切り替えて再度sudoする
# wheelグループにユーザーを追加する
$ sudo usermod -aG wheel ponsuke

# 追加された
$ cat /etc/group | grep wheel
wheel:x:10:centos,ponsuke

# ユーザーを切り替えて
$ sudo su - ponsuke
Last login: Mon May  4 02:57:57 UTC 2020 on pts/0

# 再度sudoする
$ sudo chmod 700 ~/.ssh/id_rsa
[sudo] password for ponsuke:

# できた!
$ ls -la ~/.ssh/ | grep id_rsa
-rwx------. 1 centos     centos     1675 May  4 02:38 id_rsa
20
17
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
20
17