sudo su 비밀번호를 변경한 후에도 비밀번호를 묻지 않습니다.

sudo su 비밀번호를 변경한 후에도 비밀번호를 묻지 않습니다.

AWS에 우분투 인스턴스가 있습니다.
SSH 로그인을 받은 후 명령을 사용하여 루트 비밀번호를 변경할 수 있었습니다 sudo su.
보안상의 이유로 루트 비밀번호를 변경하고 싶었습니다. 그래서 나는 다음을 시도했습니다.

root@email:/home/ubuntu# sudo passwd root
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@email:/home/ubuntu# 

비밀번호를 변경하려고 하면 sudo su비밀번호를 묻지 않습니다.

ubuntu@email:~$ sudo su
root@email:/home/ubuntu# 

반면에 만 시도하면 su다음 중 하나를 묻는 메시지가 나타납니다.

ubuntu@email:~$ su
Password: 

보안을 구현하거나 비밀번호를 설정하는 방법은 무엇입니까 sudo su?

다음은 sudoers(visudo)의 세부정보입니다.

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

답변1

sudoers파일 의 이 줄

#includedir /etc/sudoers.d

/etc/sudoers.d/디렉토리 의 다른 파일을 포함하게 만듭니다 . 해당 줄이 주석 처리된 것처럼 보일 수도 있지만 그렇지 않습니다. 지시문은 #includedirLeading 입니다 #. 포함된 파일 중 하나가 NOPASSWD문제를 일으키는 규칙을 설정했을 수 있습니다 .

무언가를 변경하기 전에 일반 사용자가 비어 있지 않은 유효한 비밀번호를 가지고 있는지 확인하세요. 에서이 답변:

sudo비밀번호가 없는 경우에도 비밀번호를 묻는 메시지가 표시되며 빈 비밀번호는 허용되지 않습니다.

확실하지 않은 경우 passwd일반 사용자에 대해 새로운 비밀번호를 호출하고 설정하세요.

이 명령은 검사해야 할 파일이 무엇인지 알려줍니다.

sudo grep -r NOPASSWD /etc/sudoers.d/

원하는 라인은 다음과 같습니다.

ubuntu ALL=(ALL) NOPASSWD:ALL

주석( )으로 처리하세요 # ubuntu ALL=.... 비교하다이 답변.

관련 정보