Simulation is ...

Virtual = Real

Flight Sim 자세히보기

ㆍ Linux

[Linux, CentOS] root 계정 su 제한하는 방법

FlightSim 2020. 9. 11. 10:46
320x100

특정 사용자 (wheel 그룹)만 su 명령어 사용

 

아래 빨간색으로 강조된 부분 "auth required pam_wheel.so use_uid" 의 주석을 제거하거나 코멘트(#)로 주석 처리하여 su 명령어 사용을 wheel 그룹에 포함된 사용자로 제한.

 

[root@ ~]# vi /etc/pam.d/su

 

#%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 include system-auth

account sufficient pam_succeed_if.so uid = 0 use_uid quiet

account include system-auth

password include system-auth

session include system-auth

session optional pam_xauth.so

 

wheel 그룹에 사용자 추가

 

su 명령어를 사용할 계정을 wheel 그룹에 추가.

 

[root@ ~]# vi /etc/group

 

root:x:0:

bin:x:1:

daemon:x:2:

sys:x:3:

adm:x:4:

tty:x:5:

disk:x:6:

lp:x:7:

mem:x:8:

kmem:x:9:

wheel:x:10:root,flight,sim 

...

 

위와 같이 "wheel:x:10:사용자계정" 이런식으로 계정 추가

(그룹에 추가하는 명령어도 있지만 그냥 직접 추가).

 

su 파일의 권한 수정

일반 사용자는 사용하지 못하게 하고 wheel 그룹에 속한 사용자만 su 명령어를 사용할 수 있도록 권한 수정.

 

[root@ ~]# which su

 

/bin/su 

[root@ ~]# ls- al /bin/su 

-rwsr-xr-x 1 root root 23960 Sep 11 10:33 /bin/su

 

먼저 su 위치를 which 명령어를 이용하여 확인하고 ls -al 명령어로 조회.

그러면 위처럼 "-rwsr-xr-x. 1 root root" 의 권한을 가짐

 

 

[root@ ~]# chgrp wheel /bin/su 

[root@ ~]# ls -al /bin/su 

-rwxr-xr-x 1 root wheel 23960 Sep 11 10:33 /bin/su

 

su 사용 그룹 권한을 wheel로 변경.

wheel 그룹으로 변경하면 위와 같이 su 파일의 Permission 이 rws 에서 rwx 로 변경됨.

 

 

[root@ ~]# chmod 4750 /bin/su 

[root@ ~]# ls -al /bin/su 

-rwsr-x--- 1 root wheel 23960 Sep 11 10:33 /bin/su

 

Permission 정보를 4750 으로 변경

320x100
반응형