LoginSignup
1
0

More than 3 years have passed since last update.

(メモ)su させない

Posted at

/etc/sudoers.dディレクトリ配下を編集

rootユーザで/etc/sudoers.d配下に ban_commandファイル(このファイル名はなんでもいい)を作成。

# cd /etc/sudoers.d
# touch ban_command
# vi /etc/sudoers.d/ban_command
Cmnd_Alias BAN_COMMAND = /bin/su
<ユーザ名> ALL=NOPASSWD: ALL, !BAN_COMMAND

visudoで内容を確認し、「:q」でvisudoから抜ける

# visudo

suできないか確認

「Sorry〜」のメッセージが出力されればOK

$ su - <ユーザー名>
$ sudo su
Sorry, user <ユーザ名> is not allowed to execute '/bin/su' as root on ip-xx-xxx-xx-xx.ap-northeast-1.compute.internal.

参考

sudoを/etc/sudoers.d/fileで許可する

1
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
1
0