authselect
특정 프로필을 선택하여 시스템 ID 및 인증 소스를 구성할 수 있는 유틸리티다.
사용법
authselect [OPTIONS] PROFILE |
authconfig 옵션
옵션 | 설명 |
-b | 백업 파일로 만든다 |
select | 프로필을 선택한다 |
apply-changes | 현재 선택된 명령에 대한 구성 재생성 |
list | 사용 가능한 프로필을 나열한다 |
list-feature | 적용가능한 feature을 보여준다 |
enable-feature | feature를 적용한다 |
create-profile | 새로운 프로필을 생성한다 |
-f | 강제로 실행한다 |
록키9 인증시스템 설정파일 만들기
sssd 모듈을 사용하는 새 인증 프로필을 생성하는것으로 sssd 모듈은 System Security Services Daemon의 약자로 보안서비스시스템 데몬의 약자이다.
[root@localhost etc]# authselect create-profile local -b sssd New profile was created at /etc/authselect/custom/local # 기존파일을 건드리는것은 좋지 않기때문에 -b옵션을 사용해서 sssd 백업파일을 만든다. [root@localhost etc]# authselect list # 현재 사용가능한 프로파일 목록을 출력한다. - minimal Local users only for minimal installations - sssd Enable SSSD for system authentication (also for local users only) - winbind Enable winbind for system authentication - custom/local Enable SSSD for system authentication (also for local users only) |
test프로파일 생성
[root@localhost pam.d]# authselect create-profile test -b minimal New profile was created at /etc/authselect/custom/test [root@localhost pam.d]# authselect select custom/test "custom/test"프로필을 선택했습니다. #생성한 test를 선택 [root@localhost pam.d]# authselect apply-changes #이후에 변경사항 적용 [root@localhost pam.d]# authselect current Profile ID: custom/test Enabled features: - with-faillock #현재 적용된 authselect 확인 [root@localhost pam.d]# vi /etc/pam.d/password-auth 에서 파일을 수정하는것이아닌 (정확한 열과 내용을 입력해야함으로 고난이도수정이다.) [root@localhost pam.d]# vi /etc/security/faillock.conf 이쪽에서 수정해야 한다. 한 후에는 꼭 authselect apply-changes 사용하여 설정을 바꿔줘야함. |
1. faillock 설정
RHEL 7버전
[root@rocky1 ~]# authconfig --enablefaillock --faillockargs="deny=5 unlock_time=120" --update |
[root@rocky1 ~]# vi /etc/sysconfig/authconfig # vi 편집기 CACHECREDENTIALS=yes FAILLOCKARGS="deny=5 unlock_time=120" # 해당 부분에 자동적용됨 ... |
[root@rocky1 ~]# vi /etc/pam.d/password-auth # vi 편집기 # This file is auto-generated. # User changes will be destroyed the next time authconfig is run. auth required pam_env.so auth required pam_faildelay.so delay=2000000 auth required pam_faillock.se preauth silent deny=5 unlock_tume=120 # 해당 부분에 자동 적용됨 ... |
RHEL 8 이상
[root@rocky1 pam.d]# authselect enable-feature with-faillock #현재 프로필에 faillock 기능추가 [root@rocky1 pam.d]# vi /etc/security/faillock.conf #추가된 faillock 설정을 커스텀 ex) deny=5 설정 [root@rocky1 pam.d]# authselect apply-changes #변경사항 저장 [root@rocky1 pam.d]# ssh asd@localhost #설정된 faillock 기능 실험 asd@localhost's password: #1번 실패 Permission denied, please try again. asd@localhost's password: #2번 실패 Permission denied, please try again. asd@localhost's password: #3번 실패 asd@localhost: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@rocky1 pam.d]# ssh asd@localhost asd@localhost's password: #4번 실패 Permission denied, please try again. asd@localhost's password: #5번 실패 Permission denied, please try again. asd@localhost's password: #6번 실패 asd@localhost: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). [root@rocky1 pam.d]# ssh asd@localhost asd@localhost's password: # 정상 암호 입력 했지만 실패 Permission denied, please try again. [root@rocky1 pam.d]# faillock #faillock 명령어를 사용, 로그인 실패를 리스트로 보여준다 asd: When Type Source Valid 2023-05-15 14:22:37 RHOST ::1 V 2023-05-15 13:27:57 RHOST ::1 I 2023-05-15 14:22:22 RHOST ::1 V 2023-05-15 14:22:27 RHOST ::1 V 2023-05-15 14:22:30 RHOST ::1 V [root@rocky1 pam.d]# faillock --reset --user asd # faillock으로 잠긴 계정 리셋 [root@rocky1 pam.d]# ssh asd@localhost #재접속 asd@localhost's password: Last failed login: Mon May 15 14:22:58 KST 2023 from ::1 on ssh:notty There were 64 failed login attempts since the last successful login. [asd@rocky1 ~]$ #asd 계정에 접속됨 |
2. pwquality파일 설정
비밀번호 설정에 따라야하는 룰북을 작성할 수 있다.
[root@localhost /]# vi /etc/security/pwquality.conf # old password. # difok = 1 #기존 암호와 같은 문자개수를 설정한다. # (0일시 이전패스워드와 같은지만 확인한다.) # Minimum acceptable size for the new password (plus one if # credits are not disabled which is the default). (See pam_cracklib manual.) # Cannot be set to lower value than 6. # minlen = 8 #패스워드의 최소 문자수를 설정한다. # (6보다 작은수를 설정할 수 없다.) # The maximum credit for having digits in the new password. If less than 0 # it is the minimum number of digits in the new password. # dcredit = 0 #숫자를 포함해야하는 문자수를 설정한다. # (음수일때 최소포함개수, 양수일때는 숫자문자가 얻을 수 있는 최대값이다.) # The maximum credit for having uppercase characters in the new password. # If less than 0 it is the minimum number of uppercase characters in the new # password. # ucredit = 0 #대문자의 개수요구 옵션 # # The maximum credit for having lowercase characters in the new password. # If less than 0 it is the minimum number of lowercase characters in the new # password. # lcredit = 0 #소문자의 개수요구 옵션 # # The maximum credit for having other characters in the new password. # If less than 0 it is the minimum number of other characters in the new # password. # ocredit = 0 #특수문자의 개수요구 옵션 # # The minimum number of required classes of characters for the new # password (digits, uppercase, lowercase, others). # minclass = 0 #최소 종류요구옵션 (대문자,소문자,특수문자,숫자등) # # The maximum number of allowed consecutive same characters in the new password. # The check is disabled if the value is 0. # maxrepeat = 0 #연달아서 같은 문자최대개수요구 옵션 # # The maximum number of allowed consecutive characters of the same class in the # new password. # The check is disabled if the value is 0. # maxclassrepeat = 0 #연달아서 같은종류의 문자 최대개수요구 옵션 # (2로 설정시 같은종류의 문자를 2개연달아쓸수 없다.) # Whether to check for the words from the passwd entry GECOS string of the user. # The check is enabled if the value is not 0. # gecoscheck = 0 #파일내의 같은단어는 사용요구 옵션 ‘0이아닐시 활성화됨’ # (/etc/passwd 파일내의 파일안에서 중복단어를확인한다.) # Whether to check for the words from the cracklib dictionary. # The check is enabled if the value is not 0. # dictcheck = 1 #사전에 등록되어있는단어검색 옵션 ‘0이아닐시 활성화’ # (cracklib에 등록되어있는 단어일시 사용하지못함) # Whether to check if it contains the user name in some form. # The check is enabled if the value is not 0. # usercheck = 1 #유저이름에 포함된형식검색 옵션 ‘0이아닐시 활성화’ # (유저이름과 비밀번호 를대조하여 중복일시 사용하지못함) # Length of substrings from the username to check for in the password # The check is enabled if the value is greater than 0 and usercheck is enabled. # usersubstr = 0 #패스워드 최소문자열검사 검색옵션 ‘0이아닐시 활성화’ # # Whether the check is enforced by the PAM module and possibly other # applications. # The new password is rejected if it fails the check and the value is not 0. # enforcing = 1 #검사에 실패한 비밀번호를 거부한다. # # Path to the cracklib dictionaries. Default is to use the cracklib default. # dictpath = #dictcheck = 에 사용되는 경로를 지정할 수 있다. # # Prompt user at most N times before returning with error. The default is 1. # retry = 3 #재시도 기회 옵션 # # Enforces pwquality checks on the root user password. # Enabled if the option is present. # enforce_for_root #비밀번호 변경 에대한 root 권한 설정옵션 # (disabled 사용시 root의 비밀번호 변경시 같은옵션을 적용한다.) # Skip testing the password quality for users that are not present in the # /etc/passwd file. # Enabled if the option is present. # local_users_only |
* credit 예시
credit이 음수일경우
[root@rocky1 ~]# vi /etc/security/pwquality.conf # vi 편집창 ... minlen = 8 # 글자수 8으로 지정 dcredit = -2 # 숫자 credit을 -2로 지정 ... # admin으로 로그인 후 암호 변경 [admin@rocky1]~% passwd Changing password for user admin. Current password: New password: dkaghdpdy0 # 숫자의 갯수가 2보다 적음 BAD PASSWORD: The password contains less than 2 digits New password: dka02 # 숫자의 갯수는 채웠으나 지정한 글자수보다 짧음 BAD PASSWORD: The password is shorter than 8 characters New password: dkaghd02 # 숫자와 글자수를 모두 만족함 Retype new password: # 변경할 암호의 최소 자릿수 = 숫자 2자리(필수) + 임의의 문자 6자리 |
credit이 음수일 경우 포함해야하는 최소 credit의 수(최소 숫자의 개수)를 반드시 만족해야 한다.
총 글자수를 만족해도 입력한 credit수가 지정한 credit수보다 작으면 변경 불가.
credit이 양수일경우
[root@rocky1 ~]# vi /etc/security/pwquality.conf # vi 편집창 ... minlen = 8 # 글자수 8으로 지정 dcredit = 2 # 숫자 credit을 2로 지정 ... # admin으로 로그인 후 암호 변경 [admin@rocky1]~% passwd Changing password for user admin. Current password: New password: dka02 # 숫자의 갯수를 채우면 2만큼 글자수를 줄여줌 BAD PASSWORD: The password is shorter than 6 characters New password: dkag0 # 숫자를 하나만 채워도 1만큼 글자수를 줄여줌 BAD PASSWORD: The password is shorter than 7 characters New password: dkag02 # 숫자가 2개 포함됐기 때문에 6글자만 입력해도 만족 Retype new password: New password: dkaghdpdy # 숫자의 갯수를 채우지 않아도 글자수만 채워도 만족 Retype new password: # 변경할 암호의 최소 자릿수 = 숫자 2자리 + 임의의 문자 4자리 # = 숫자 1자리 + 임의의 문자 6자리 # = 숫자 0자리 + 임의의 문자 8자리 |
credit이 양수일 경우 굳이 credit을 입력하지 않아도 암호를 변경할 수 있다.
다만, credit을 입력하면 지정한 credit만큼 추가로 글자수를 줄여준다.