su 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-su
핵심 정리
- 지금 세션의 사용자를 root나 지정한 사용자로 바꾸고 새 셸을 엽니다.
exit나 Ctrl+D로 돌아옵니다. su 사용자는 지금 환경과 디렉터리를 그대로 두고,su - 사용자는 그 사용자로 로그인한 것처럼 환경(프로필, 홈 디렉터리)을 새로 만듭니다.- 명령 하나만 실행하려면
su - 사용자 -c "명령"처럼 셸 인수를 넘깁니다. - 실행할 때마다
/var/adm/sulog에 날짜, 시간, 결과(+성공,-실패), 사용자를 남깁니다. - 대상 계정의
su속성이false이거나sugroups에 지금 사용자의 그룹이 없으면 실패합니다(chuser su=,sugroups=로 정함).
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (6.1에서 su --, domainlessgroups, Trusted AIX 레이블 조건, RBAC 권한 안내가 더해짐) |
| 원문 | IBM Commands Reference — 5.3 Volume 5, 6.1 Volume 5 |
| 파일 | /usr/bin/su, /var/adm/sulog, /etc/security/user, /etc/pam.conf |
| 관련 명령어 | login, sudo, chuser(su, sugroups), tsh, who am i |
목적
세션에 연결된 사용자 ID를 바꿉니다.
영어 원문
Changes the user ID associated with a session.
구문
su [ - ] [ Name [ Argument ... ] ]
설명
su 명령은 사용자 자격 증명을 root나 Name 매개변수로 지정한 사용자로 바꾸고 새 세션을 시작합니다. 사용자 이름에 DCE 셀 지정을 넣을 수도 있습니다.
참고: root는 DCE 사용자로 바꿀 때 DCE 인증을 거치지 않아도 되며, 이때 그 사용자의 DCE 자격 증명도 필요 없습니다.
Argument 매개변수로 준 플래그나 매개변수는 Name 사용자의 로그인 셸에 맞는 것이어야 하며, 그 셸에 넘겨집니다. 예를 들어 사용자 Fred의 로그인 셸이 /usr/bin/csh면 csh의 -f를 줄 수 있고, 그러면 csh가 .cshrc 시작 스크립트를 건너뜁니다.
(6.1) 참고: /etc/secvars.cfg에 domainlessgroups 속성이 정해져 있고 사용자가 LDAP 도메인이나 files 도메인에 속하면, 그룹 ID를 LDAP과 files 도메인에서 모두 가져옵니다.
su는 다음 일을 차례로 합니다. 하나가 실패하면 그 뒤의 일은 하지 않습니다(각 의미는 ckuseracct, ckuserID, authenticate, setpcred, setpenv 서브루틴 참고).
| 단계 | 하는 일 |
|---|---|
| 계정 검사 | 계정이 있는지, su가 허락되는지, 지금 사용자가 이 계정으로 su할 수 있는 그룹에 있는지, 지금 제어 단말에서 쓸 수 있는지 확인 |
| 사용자 인증 | 시스템이 정한 주 인증 방법으로 신원을 확인. 비밀번호가 만료됐으면 새 비밀번호를 넣어야 함 |
| 자격 증명 설정 | 사용자 데이터베이스의 값으로 처음 자격 증명(접근 권한과 책임)을 정함 |
| 세션 시작 | -를 주면 사용자 데이터베이스와 /etc/environment의 값으로 사용자 환경을 초기화. -가 없으면 디렉터리도 바꾸지 않음 |
이전 세션으로 돌아가려면 exit를 입력하거나 Ctrl+D를 누릅니다. su가 부른 셸이 끝나고 이전 셸, 사용자 ID, 환경으로 돌아갑니다.
신뢰 셸 /usr/bin/tsh에서 su를 실행하면 그 셸을 빠져나갑니다. su는 제어 단말의 보안 특성을 바꾸지 않습니다.
su를 실행할 때마다 /var/adm/sulog에 날짜, 시간, 시스템 이름, 로그인 이름과 성공 여부(+ 성공, - 실패)를 기록합니다.
참고: su가 성공해도 /etc/security/lastlog의 unsuccessful_login_count는 /etc/security/user에서 그 사용자의 rlogin과 login이 모두 false일 때만 되돌립니다. 관리자가 사용자 계정 문제를 고치려고 su를 자주 쓰기 때문이며, 사용자는 로컬이나 원격 로그인으로 이 값을 되돌릴 수 있습니다.
영어 원문
The su command changes user credentials to those of the root user or to the user specified by the Name parameter, and initiates a new session. The user name might include a Distributed Computing Environment (DCE) cell specification.
Note: The root user is not required to satisfy the DCE authentication when switching to a DCE user. In this case, the user's DCE credentials are not required.
Any arguments, such as flags or parameters, that are specified by the Arguments parameter must relate to the login shell defined for the user specified by the Name parameter. These arguments are passed to the specified user's login shell. For example, if the login shell for user Fred is /usr/bin/csh, you can include any of the flags for the csh command, such as the -f flag. When the su command runs, it passes the -f flag to the csh command. When the csh command runs, the -f flag omits the .cshrc startup script.
Note: If the domainlessgroups attribute is set in the /etc/secvars.cfg file and if the user belongs to the Lightweight Directory Access Protocol (LDAP) domain or files domain, all the group IDs are fetched from the LDAP domain and the files domain.
The following functions are performed by the su command:
- account checking — Validates the user account to be certain it exists, that it is enabled for the su command, that the current user is in a group permitted to switch to this account with the su command, and that it can be used from the current controlling terminal.
- user authentication — Validates the user's identity, using the system-defined primary authentication methods for the user. If a password has expired, the user must supply a new password.
- credentials establishment — Establishes initial user credentials, using the values in the user database. These credentials define the user's access rights and accountability on the system.
- session initiation — If the
-flag is specified, the su command initializes the user environment from the values in the user database and the /etc/environment file. When the-flag is not used, the su command does not change the directory.
These functions are performed in the sequence shown. If one function is unsuccessful, the succeeding functions are not done. Refer to the ckuseracct, ckuserID, authenticate, setpcred, and setpenv subroutines for the semantics of these functions.
To restore the previous session, type exit or press the Ctrl-D key sequence. This action ends the shell called by the su command and returns you to the previous shell, user ID, and environment.
If the su command is run from the /usr/bin/tsh shell, the trusted shell, you exit from that shell. The su command does not change the security characteristics of the controlling terminal.
Each time the su command is executed, an entry is made in the /var/adm/sulog file. The /var/adm/sulog file records the following information: date, time, system name, and login name. The /var/adm/sulog file also records whether or not the login attempt was successful: a + (plus sign) indicates a successful login, and a - (minus sign) indicates an unsuccessful login.
Note: Successful use of the su command resets the unsuccessful_login_count attribute in the /etc/security/lastlog file only if the user's rlogin and login attributes are both set to false in /etc/security/user. Otherwise, the su command doesn't reset the unsuccessful_login_count, because the administrator often uses the su command to fix user account problems. The user is able to reset the attribute through a local or remote login.
플래그
| 플래그 | 설명 |
|---|---|
- |
login 명령으로 로그인한 것처럼 프로세스 환경을 정합니다. 지금 환경은 새 셸에 전혀 넘어가지 않습니다. (6.1) 다른 UNIX 셸 환경과 호환되도록 Name 앞에 이 옵션을 둡니다. |
영어 원문
-— Specifies that the process environment is to be set as if the user had logged in to the system using the login command. Nothing in the current environment is propagated to the new shell. Note: This behavior is intended for compatibility with alternate UNIX shell environments where flag options are allowed ahead of the Name parameter.
보안
su는 서비스 이름이 su인 PAM 지원 응용 프로그램입니다. 시스템 전체에서 PAM으로 인증하게 하려면 root가 /etc/security/login.cfg의 usw 스탠자에서 auth_type을 PAM_AUTH로 바꿉니다.
PAM을 켰을 때의 인증 방법은 /etc/pam.conf의 su 서비스 구성에 따릅니다. su에는 auth, account, password, session 모듈 유형 항목이 필요합니다. 표준 AIX 인증과 같게 동작하려면 auth와 account 스택에서 pam_allowroot를 sufficient로 pam_aix보다 먼저 불러야 합니다. 권하는 구성은 다음과 같습니다.
#
# AIX su configuration
#
su auth sufficient /usr/lib/security/pam_allowroot
su auth required /usr/lib/security/pam_aix
su account sufficient /usr/lib/security/pam_allowroot
su account required /usr/lib/security/pam_aix
su session required /usr/lib/security/pam_aix
su password required /usr/lib/security/pam_aix
RBAC 사용자와 Trusted AIX 사용자는 주의하세요. 이 명령은 특권 작업을 할 수 있으며, 특권 작업은 특권 사용자만 할 수 있습니다. 특권과 권한 목록은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다(6.1 문서에만 있음). 명령의 기능을 모두 쓰려면 역할에 accessauths 말고도 aix.security.su 권한이 있어야 합니다.
(6.1) Trusted AIX 시스템에서 -로 su를 실행하면 보안 레이블과 무결성 레이블 모두 다음을 만족해야 합니다.
- 지금 사용자의 최대 허가 등급이 새 사용자의 최대 허가 등급을 지배해야 합니다.
- 새 사용자의 최소 허가 등급이 지금 사용자의 최소 허가 등급을 지배해야 합니다.
- 지금 사용자의 유효 허가 등급이 새 사용자의 최대 허가 등급에 지배되고, 새 사용자의 최소 허가 등급을 지배해야 합니다.
영어 원문
The su command is a PAM-enabled application with a service name of su. System-wide configuration to use PAM for authentication is set by modifying the value of the auth_type attribute, in the usw stanza of /etc/security/login.cfg, to PAM_AUTH as the root user.
The authentication mechanisms used when PAM is enabled depend on the configuration for the su service in /etc/pam.conf. The su command requires /etc/pam.conf entries for the auth, account, password, and session module types. In order for the su command to exhibit a similar behavior through PAM authentication as seen in standard AIXauthentication, the pam_allowroot module must be used as sufficient and called before pam_aix in both the auth and account su service stacks. Listed below is a recommended configuration in /etc/pam.conf for the su service:
# # AIX su configuration # su auth sufficient /usr/lib/security/pam_allowroot su auth required /usr/lib/security/pam_aix
su account sufficient /usr/lib/security/pam_allowroot su account required /usr/lib/security/pam_aix
su session required /usr/lib/security/pam_aix
su password required /usr/lib/security/pam_aix
Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand. To get the full functionality of the command, besides the accessauths, the role should also have the aix.security.su authorization.
On a Trusted AIX system, when the su command is invoked with the - flag, the following conditions must be met for both sensitivity and integrity labels:
The current user's maximum clearance must dominate the new user's maximum clearance.
The new user's minimum clearance must dominate the current user's minimum clearance.
The current user's effective clearance must be dominated by the new user's maximum clearance and must dominate the new user's minimum clearance.
예제
| 명령 | 하는 일 |
|---|---|
su |
root의 유효 사용자 ID와 특권으로 하위 셸을 실행. root 비밀번호를 묻고, Ctrl+D로 끝내면 원래 셸로 돌아옴 |
su -- |
(6.1) 위와 같음 |
su jim |
jim의 유효 사용자 ID와 특권으로 하위 셸을 실행 |
su - jim |
jim으로 로그인한 것처럼 환경을 만들어 하위 셸을 실행 |
su root "-c /usr/sbin/backup -9 -u" |
root의 기본 셸에서 root 권한으로 backup을 실행하고 원래 셸로 돌아옴. root 비밀번호를 맞게 넣어야 실행됨 |
su -, su - root, su - -- |
(6.1) root의 로그인 환경으로 하위 셸을 시작 |
자주 쓰는 형태:
su - oracle # 응용 계정으로(프로필 적용)
su - oracle -c "lsnrctl status" # 명령 하나만
tail /var/adm/sulog # 누가 언제 su했는지
lsuser -a su sugroups root # root로 su할 수 있는 그룹
영어 원문
- To obtain root user authority, enter one of the following commands:
su
This command runs a subshell with the effective user ID and privileges of the root user. You will be asked for the root password. Press End-of-File, Ctrl+D key sequence, to end the subshell and return to your original shell session and privileges.
su --
This command runs a subshell with the effective user ID and privileges of the root user. Enter the root password, when prompted. Press End-of-File, Ctrl+D key sequence, to end the subshell and return to your original shell session and privileges.
- To obtain the privileges of the
jimuser, enter the following command:
su jim
This command runs a subshell with the effective user ID and privileges of jim.
- To set up the environment as if you had logged in as the
jimuser, enter:
su - jim
This starts a subshell using jim's login environment.
- To run the backup command with root user authority and then return to your original shell, enter:
su root "-c /usr/sbin/backup -9 -u"
This command runs the backup command with root user authority within root's default shell. You must give the correct root password when queried for the command to execute.
- Enter one of the following commands to change the user credentials of the current session to root user:
su - su - root su - -- The preceding commands start a subshell by using the root user's login environment.
파일
| 파일 | 설명 |
|---|---|
/usr/bin/su |
su 명령 |
/etc/environment |
사용자 환경 값 |
/etc/group |
그룹의 기본 속성 |
/etc/passwd |
사용자의 기본 속성 |
/etc/security/user |
사용자의 확장 속성 |
/etc/security/environ |
사용자의 환경 속성 |
/etc/security/limits |
사용자의 프로세스 자원 한도 |
/etc/security/passwd |
비밀번호 정보 |
/var/adm/sulog |
su 시도 기록 |
/etc/security/enc/LabelEncodings |
Trusted AIX의 레이블 정의 |
영어 원문
- /usr/bin/su — Contains the su command.
- /etc/environment — Contains user environment values.
- /etc/group — Contains the basic group attributes.
- /etc/passwd — Contains the basic user attributes.
- /etc/security/user — Contains the extended attributes of users.
- /etc/security/environ — Contains the environment attributes of users.
- /etc/security/limits — Contains the process resource limits of users.
- /etc/security/passwd — Contains password information.
- /var/adm/sulog — Contains information about login attempts.
- /etc/security/enc/LabelEncodings — Contains label definitions for the Trusted AIX system.
Related reference:
- tsh Command
- tsm Command
Related information:
- bsh command
- Securing the network
리눅스(GNU)와 다른 점
리눅스 su도 su 사용자, su - 사용자, su - 사용자 -c "명령"으로 쓰며 PAM(/etc/pam.d/su)으로 인증합니다. 기록은 sulog 대신 /var/log/secure(RHEL)나 /var/log/auth.log(Debian), journalctl _COMM=su에 남습니다. su할 수 있는 사용자를 제한하는 AIX sugroups는 리눅스에서 pam_wheel(wheel 그룹)로 하며, 요즘은 sudo를 더 많이 씁니다.