useradd의 환경을 지배하는 3개의 파일(디렉토리)실무3편-useradd가 참조하는 파일 : /etc/login.defs파일 실무활용
작성자 정보
- 관리자 작성
- 작성일
컨텐츠 정보
- 2,891 조회
- 0 추천
- 목록
본문
useradd의 환경을 지배하는 3개의 파일(디렉토리)실무3편
부제: useradd가 참조하는 파일 : /etc/login.defs파일 실무활용
useradd의 환경을 지배하는 두번째 파일로서 /etc/login.defs에 대한 설명이다.
/etc/login.defs파일은 useradd가 새로운 계정을 생성할 때에 반드시 참조하는 파일이다.
먼저 이 파일의 내용을 확인해보도록 하자.
[root@RockyLinux01 ~]# cat /etc/login.defs # # Please note that the parameters in this configuration file control the # behavior of the tools from the shadow-utils component. None of these # tools uses the PAM mechanism, and the utilities that use PAM (such as the # passwd command) should therefore be configured elsewhere. Refer to # /etc/pam.d/system-auth for more information. #
# # Delay in seconds before being allowed another attempt after a login failure # Note: When PAM is used, some modules may enforce a minimum delay (e.g. # pam_unix(8) enforces a 2s delay) # #FAIL_DELAY 3
# Currently FAILLOG_ENAB is not supported
# # Enable display of unknown usernames when login(1) failures are recorded. # #LOG_UNKFAIL_ENAB no
# Currently LOG_OK_LOGINS is not supported
# Currently LASTLOG_ENAB is not supported
# # Limit the highest user ID number for which the lastlog entries should # be updated. # # No LASTLOG_UID_MAX means that there is no user ID limit for writing # lastlog entries. # #LASTLOG_UID_MAX
# Currently MAIL_CHECK_ENAB is not supported
# Currently OBSCURE_CHECKS_ENAB is not supported
# Currently PORTTIME_CHECKS_ENAB is not supported
# Currently QUOTAS_ENAB is not supported
# Currently SYSLOG_SU_ENAB is not supported
# # Enable "syslog" logging of newgrp(1) and sg(1) activity. # #SYSLOG_SG_ENAB yes
# Currently CONSOLE is not supported
# Currently SULOG_FILE is not supported
# Currently MOTD_FILE is not supported
# Currently ISSUE_FILE is not supported
# Currently TTYTYPE_FILE is not supported
# Currently FTMP_FILE is not supported
# Currently NOLOGINS_FILE is not supported
# Currently SU_NAME is not supported
# *REQUIRED* # Directory where mailboxes reside, _or_ name of file, relative to the # home directory. If you _do_ define both, MAIL_DIR takes precedence. # MAIL_DIR /var/spool/mail #MAIL_FILE .mail
# # If defined, file which inhibits all the usual chatter during the login # sequence. If a full pathname, then hushed mode will be enabled if the # user's name or shell are found in the file. If not a full pathname, then # hushed mode will be enabled if the file exists in the user's home directory. # #HUSHLOGIN_FILE .hushlogin #HUSHLOGIN_FILE /etc/hushlogins
# Currently ENV_TZ is not supported
# Currently ENV_HZ is not supported
# # The default PATH settings, for superuser and normal users. # # (they are minimal, add the rest in the shell startup files) #ENV_SUPATH PATH=/sbin:/bin:/usr/sbin:/usr/bin #ENV_PATH PATH=/bin:/usr/bin
# # Terminal permissions # # TTYGROUP Login tty will be assigned this group ownership. # TTYPERM Login tty will be set to this permission. # # If you have a write(1) program which is "setgid" to a special group # which owns the terminals, define TTYGROUP as the number of such group # and TTYPERM as 0620. Otherwise leave TTYGROUP commented out and # set TTYPERM to either 622 or 600. # #TTYGROUP tty #TTYPERM 0600
# Currently ERASECHAR, KILLCHAR and ULIMIT are not supported
# Default initial "umask" value used by login(1) on non-PAM enabled systems. # Default "umask" value for pam_umask(8) on PAM enabled systems. # UMASK is also used by useradd(8) and newusers(8) to set the mode for new # home directories if HOME_MODE is not set. # 022 is the default value, but 027, or even 077, could be considered # for increased privacy. There is no One True Answer here: each sysadmin # must make up their mind. UMASK 022
# HOME_MODE is used by useradd(8) and newusers(8) to set the mode for new # home directories. # If HOME_MODE is not set, the value of UMASK is used to create the mode. HOME_MODE 0700
# Password aging controls: # # PASS_MAX_DAYS Maximum number of days a password may be used. # PASS_MIN_DAYS Minimum number of days allowed between password changes. # PASS_MIN_LEN Minimum acceptable password length. # PASS_WARN_AGE Number of days warning given before a password expires. # PASS_MAX_DAYS 99999 PASS_MIN_DAYS 0 PASS_WARN_AGE 7
# Currently PASS_MIN_LEN is not supported
# Currently SU_WHEEL_ONLY is not supported
# Currently CRACKLIB_DICTPATH is not supported
# # Min/max values for automatic uid selection in useradd(8) # UID_MIN 1000 UID_MAX 60000 # System accounts SYS_UID_MIN 201 SYS_UID_MAX 999 # Extra per user uids SUB_UID_MIN 100000 SUB_UID_MAX 600100000 SUB_UID_COUNT 65536
# # Min/max values for automatic gid selection in groupadd(8) # GID_MIN 1000 GID_MAX 60000 # System accounts SYS_GID_MIN 201 SYS_GID_MAX 999 # Extra per user group ids SUB_GID_MIN 100000 SUB_GID_MAX 600100000 SUB_GID_COUNT 65536
# # Max number of login(1) retries if password is bad # #LOGIN_RETRIES 3
# # Max time in seconds for login(1) # #LOGIN_TIMEOUT 60
# Currently PASS_CHANGE_TRIES is not supported
# Currently PASS_ALWAYS_WARN is not supported
# Currently PASS_MAX_LEN is not supported
# Currently CHFN_AUTH is not supported
# # Which fields may be changed by regular users using chfn(1) - use # any combination of letters "frwh" (full name, room number, work # phone, home phone). If not defined, no changes are allowed. # For backward compatibility, "yes" = "rwh" and "no" = "frwh". # #CHFN_RESTRICT rwh
# Currently LOGIN_STRING is not supported
# Currently MD5_CRYPT_ENAB is not supported
# # If set to MD5, MD5-based algorithm will be used for encrypting password # If set to SHA256, SHA256-based algorithm will be used for encrypting password # If set to SHA512, SHA512-based algorithm will be used for encrypting password # If set to BLOWFISH, BLOWFISH-based algorithm will be used for encrypting password # If set to DES, DES-based algorithm will be used for encrypting password (default) # ENCRYPT_METHOD SHA512
# # Only works if ENCRYPT_METHOD is set to SHA256 or SHA512. # # Define the number of SHA rounds. # With a lot of rounds, it is more difficult to brute-force the password. # However, more CPU resources will be needed to authenticate users if # this value is increased. # # If not specified, the libc will choose the default number of rounds (5000). # The values must be within the 1000-999999999 range. # #SHA_CRYPT_MAX_ROUNDS 5000
# Currently SHA_CRYPT_MIN_ROUNDS is not supported
# Currently BCRYPT_MIN_ROUNDS and BCRYPT_MAX_ROUNDS are not supported
# Currently CONSOLE_GROUPS is not supported
# # Should login be allowed if we can't cd to the home directory? # Default is yes. # #DEFAULT_HOME yes
# Currently ENVIRON_FILE is not supported
# # If defined, this command is run when removing a user. # It should remove any at/cron/print jobs etc. owned by # the user to be removed (passed as the first argument). # #USERDEL_CMD /usr/sbin/userdel_local
# # Enables userdel(8) to remove user groups if no members exist. # USERGROUPS_ENAB yes
# # If set to a non-zero number, the shadow utilities will make sure that # groups never have more than this number of users on one line. # This permits to support split groups (groups split into multiple lines, # with the same group ID, to avoid limitation of the line length in the # group file). # # 0 is the default value and disables this feature. # #MAX_MEMBERS_PER_GROUP 0
# # If useradd(8) should create home directories for users by default (non # system users only). # This option is overridden with the -M or -m flags on the useradd(8) # command-line. # CREATE_HOME yes
# # Force use shadow, even if shadow passwd & shadow group files are # missing. # #FORCE_SHADOW yes
# # Select the HMAC cryptography algorithm. # Used in pam_timestamp module to calculate the keyed-hash message # authentication code. # # Note: It is recommended to check hmac(3) to see the possible algorithms # that are available in your system. # HMAC_CRYPTO_ALGO SHA512 [root@RockyLinux01 ~]# |
위에서 본 바와 같이 /etc/login.defs 파일에는 다음과 같은 정보들이 들어 있다.
MAIL_DIR /var/spool/mail
메일 디렉토리를 지정한 것이다.
즉, 사용자들의 개별메일내용이 저장되는 위치를 지정한 것이다.
예를들어 sspark사용자에게 도착한 메일은 /var/spool/mail/sspark이라는 파일로 저장된다.
결론적으로 각 계정사용자들의 메일파일이 저장될 위치를 지정한 것이다.
기본값으로 /var/spool/mail로 지정되어 있지만 이 위치를 변경함으로서 메일을 저장하는 디렉토리의 위치를 변경할 수 있다.
PASS_MAX_DAYS 99999
패스워드 변경후 재변경없이 지속적으로 사용할 수 있는 최대일자를 지정한 것이다.
즉, 99999일 동안 패스워드를 변경하지 않아도 동일한 패스워드로 그대로 사용할 수 있다.
물론 이 값을 바꾸면 그대로 적용된다.
결론적으로 계정사용자들이 패스워드를 변경하지 않고 동일한 패스워드를 지속적으로 사용할 수 있는 최대일자를 지정한 것이라고 정리하면 된다.
PASS_MIN_DAYS 0
패스워드변경 후 다시 변경할 수 있는 최소일자를 지정한 것이다.
이 값이 0이면 변경한 후에 즉시 다른 패스워드로 변경할 수 있다.
간단하게 정리하면 사용하고 있는 패스워드 변경없이 사용할 수 있는 최소일자를 지정한 것이다.
PASS_MIN_LEN 5
인정될 수 있는 패스워드의 최소길이를 지정한 것이다.
즉, 패스워드로 사용할 수 있는 최소 5바이트이상은 되어야 한다.
각 계정사용자들이 패스워드문자로 지정할 수 있는 최소바이트수(영문자수)를 지정한 것이다.
즉, 패스워드로 사용할 수 있는 최소 문자수이며 현재 5로 지정되어 있기 때문에 모든 계정사용자들이 passwd명령어로 패스워드를 지정할 때에는 반드시 5자(영문자 5자, 혹은 5bytes) 이상으로 패스워드를 입력해야 한다.
PASS_WARN_AGE 7
패스워드 사용일자가 종료되기 7일전부터 경고메시지를 보내주게 된다.
즉, 패스워드 종료일자가 다가오기 몇일 전부터 패스워드 사용불가에 대한 안내메시지를 알려줄 것인가를 지정한 것이다.
즉, 현재 7로 설정되어 있기 때문에 패스워드가 종료되기 7일전부터 패스워드가 종료된다는 것을 해당 사용자에게 알려준다.
UID_MIN 500
새로 생성되는 사용자에게 할당 할 수 있는 UID 시작번호를 지정한 것이다.
즉, 일반사용자의 UID번호를 할당할 때에 자동 할당할 최소 UID번호를 지정한 것이다.
현재 500으로 지정되어 있기 때문에 useradd명령어로 계정을 생성할 때에 UID가 500번부터 자동 할당된 것이다.
만약 일반사용자의 UID번호를 1000부터 할당하고자 한다면 이 값을 1000으로 수정해 두면 된다.
UID_MAX 60000
새로 생성되는 사용자에게 할당 할 수 있는 최대 GID 번호를 지정한 것이다.
따라서 시스템에서 생성할 수 있는 총사용자수는 UID_MAX에서 UID_MIN를 빼고 1을 더한 수만큼의 새로운 계정을 생성할 수 있음을 알 수 있다.
그렇다면 UID가 60001번인 사용자를 직접 지정하여 생성할 수 있을까? 한번 생각해보자.
이 값에 대한 의미에 대해서 좀 헷갈릴 수 있기에 다음과 같이 간단히 정리하도록 하자. 리눅스 서버에서 생성할 수 있는 UID의 최대값이다.
앞서 말했듯이 현재 이 값이 60000으로 설정되어 있기 때문에 자동 생성될 수 있는 UID는 60000까지이다.
참고로 UID_MAX에서 UID_MIN를 빼고 1을 더한 수만큼의 새로운 계정을 생성할 수 있음을 알 수 있다.
하지만 “useradd -u 70000 bible8”등과 같이 UID를 직접 지정할 때에는 이 값을 넘어서 지정할 수도 있다.
GID_MIN 500
새로 생성되는 그룹의 GID 시작번호를 지정한 것이다.
즉, 리눅스에서는 각 계정이 생성될 때에 자기 자신의 이름으로 된 그룹명을 하나씩 자동으로 생성하게 되는데 이때 GID를 몇번부터 생성할 것인가를 지정한 것이다.
/etc/group파일을 보면 새로 생성한 사용자들의 GID번호가 500번부터 할당되어 있다는 것을 알 수 있는데 그 이유가 현재 이 값이 500으로 지정되어 있기 때문이다.
GID_MAX 60000
새로 생성되는 그룹에서 지정 할 수 있는 최대 GID번호를 지정한 것이다.
즉, 새로 생성되는 그룹에서 지정 할 수 있는 최대 GID번호이다.
UID_MAX값과 함께 비교해보기 바란다.
CREATE_HOME yes
홈디렉토리를 생성할 것인가의 여부를 결정한다.
당연히 yes이면 생성하고 no이면 생성하지 않는다.
즉, 새로 생성되는 계정사용자의 홈디렉토리를 생성할 것인가를 결정하는 값이다.
이 값이 현재 yes로 되어있기 때문에 새로 생성되는 사용자의 홈디렉토리가 자동생성되는 것이며 만약 이 값이 no로 되어있다면 useradd에 의해 새로 생성되는 사용자들의 홈디렉토리는 자동으로 생성되지 않을 것이다.
UMASK 077
umask값(permission mask)을 지정한 것이다.
지정하지 않으면 022로 기본 설정된다.
USERGROUPS_ENAB yes
userdel실행시에 멤버가 없는 그룹도 삭제된다.
MD5_CRYPT_ENAB yes
패스워드 암호화를 위하여 MD5 또는 DES를 사용한다.
ENCRYPT_METHOD SHA512
위의 예에서는 없지만 이 설정은 암호화 방법으로 SHA512를 사용한다.
지금까지 /etc/login.defs파일의 내용을 주~~욱 살펴보았다.
이쯤되면 이제 여러분들은 useradd로 새로운 계정을 생성하는 작업이 그렇게 간단한것만은 아님을 느낄 수 있을 것이다.
아직 끝난 것이 아니다.
하나 더 남아있다.
다음 /etc/skel/디렉토리의 용도와 역할에 대해서 확인해 보기 바란다.
시스템관리자는 반드시 이 파일의 내용을 숙지하고 필요할 경우에는 변경하여 사용할 수 있어야 한다.
관련자료
-
이전
-
다음