리눅스

리눅스 root 계정 su 명령어 제한 방법

coinAA 2022. 10. 10.

 

 

su (Switch User) 명령어

su는 Switch User라는 뜻이며, 현재 계정을 로그아웃하지 않고 다른 계정으로 전환하는 명령어 입니다.

 

리눅스 특정 사용자 (wheel 그룹)만 su 명령어 사용 설정하기

vi /etc/pam.d/su 접속 후 아래 강조표시를 해놓은 auth sufficient pam_wheel.so trust use_uid를 주석 해제해준다.

#%PAM-1.0
auth            sufficient      pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
auth            sufficient      pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth           required        pam_wheel.so use_uid
auth            substack        system-auth
auth            include         postlogin
account         sufficient      pam_succeed_if.so uid = 0 use_uid quiet
account         include         system-auth
password        include         system-auth
session         include         system-auth
session         include         postlogin
session         optional        pam_xauth.so

리눅스 root 계정 su 명령어 제한 방법 - 리눅스 특정 사용자 (wheel 그룹)만 su 명령어 사용 설정하기
vim /etc/pam.d/su 접속 후 auth sufficient pam_wheel.so trust use_uid 주석 제거

 

su 명령어를 사용할 wheel 그룹 사용자 추가

vi /etc/group에 접속하여 su 명령어를 사용할 계정을 wheel 그룹에 추가하여야 한다.

adm:x:4:
tty:x:5:
disk:x:6:
lp:x:7:
mem:x:8:
kmem:x:9:
wheel:x:10:root,[사용자ID],[사용자ID]
cdrom:x:11:
mail:x:12:postfix
man:x:15:
dialout:x:18:
floppy:x:19:
games:x:20:
tape:x:33:

리눅스 root 계정 su 명령어 제한 방법 - su 명령어를 사용할 wheel 그룹 사용자 추가
vi /etc/group 접속 후 su명령어 사용자 추가

 

/bin/su 명령어 그룹 및 권한 변경

[root@localhost ~]#
[root@localhost ~]# ll /bin/su
-rwsr-xr-x. 1 root root 32128  2월  3  2021 /bin/su
[root@localhost ~]# chown root:wheel /bin/su
[root@localhost ~]# ll /bin/su
-rwxr-xr-x. 1 root wheel 32128  2월  3  2021 /bin/su
[root@localhost ~]# chmod 4750 /bin/su
[root@localhost ~]# ll /bin/su
-rwsr-x---. 1 root wheel 32128  2월  3  2021 /bin/su
[root@localhost ~]#

리눅스 root 계정 su 명령어 제한 방법 - /bin/su 명령어 그룹 및 권한 변경

댓글