Ubuntu 16 Sudo SU 잘못된 비밀번호 시도

Ubuntu 16 Sudo SU 잘못된 비밀번호 시도

Ubuntu 16.04.3 LTS 서버를 사용하고 있습니다. sudo 권한을 가진 사용자가 있습니다. 현재 사용자에서 루트로 전환하려고 하면 비밀번호를 묻는 메시지가 나타납니다. 올바른 비밀번호를 입력했는데 비밀번호가 거부되었습니다.

username@server:/ sudo su
[sudo] password for username:
Sorry, try again.
[sudo] password for username:
Sorry, try again.
[sudo] password for username:
sudo: 3 incorrect password attempts

다행히 아직 루트로 로그인되어 있는 다른 터미널 창이 열려 있습니다. 그래서 사용자의 비밀번호를 재설정하려고 했습니다. 사용자를 성공적으로 업데이트했다고 합니다.

root@server:/# passwd username
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

그래서 다시 명령을 시도합니다 sudo su. 동일한 메시지와 함께 실패합니다.

동일한 사용자에 대해 새 터미널 창을 열고 시도했지만 sudo su동일한 메시지와 함께 동일한 명령이 실패합니다.

나는 또한 사용자 잠금을 해제하려고 시도했습니다 sudo usermod --expiredate -1 username. 이 문제도 해결되지 않았습니다.

또한 사용자에게 "sudo" 권한을 부여해 보았습니다 usermod -aG sudo username. 그리고 사용자에게는 여전히 문제가 있었습니다.

포기하고 방금 sudo 권한을 가진 새 사용자를 만들고 새 사용자를 사용하기 시작했습니다. 다음날 나는 새로운 사용자와 똑같은 문제를 겪기 시작했습니다.

pwck명령은 여러 시스템 계정과 해당 홈 디렉터리에 대한 메시지를 나열하지만 그 외에는 아무것도 나열하지 않습니다. 이 grpck명령은 전혀 메시지를 제공하지 않습니다.

최근 약 한 달 전에 "pam" 인증을 추가했습니다.

/etc/pam.d/sudo

#%PAM-1.0

session    required   pam_env.so readenv=1 user_readenv=0
session    required   pam_env.so readenv=1 envfile=/etc/default/locale user_readenv=0
@include common-auth
@include common-account
@include common-session-noninteractive

/etc/pam.d/common-auth

auth    required        pam_tally2.so deny=5 unlock_time=600
# here are the per-package modules (the "Primary" block)
auth    [success=1 default=ignore]      pam_unix.so nullok_secure
# here's the fallback if no module succeeds
auth    requisite                       pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
auth    required                        pam_permit.so
# and here are more per-package modules (the "Additional" block)
auth    optional                        pam_cap.so
# end of pam-auth-update config

/etc/pam.d/common-account

# here are the per-package modules (the "Primary" block)
account [success=1 new_authtok_reqd=done default=ignore]        pam_unix.so
# here's the fallback if no module succeeds
account requisite                       pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
account required                        pam_permit.so
# and here are more per-package modules (the "Additional" block)
# end of pam-auth-update config

/etc/pam.d/common-session-noninteractive

# here are the per-package modules (the "Primary" block)
session [default=1]                     pam_permit.so
# here's the fallback if no module succeeds
session requisite                       pam_deny.so
# prime the stack with a positive return value if there isn't one already;
# this avoids us returning an error just because nothing sets a success code
# since the modules above will each just jump around
session required                        pam_permit.so
# The pam_umask module will set the umask according to the system default in
# /etc/login.defs and user settings, solving the problem of different
# umask settings with different shells, display managers, remote sessions etc.
# See "man pam_umask".
session optional                        pam_umask.so
# and here are more per-package modules (the "Additional" block)
session required        pam_unix.so
# end of pam-auth-update config

@telcoM과 @roaima 덕분에 pam 인증 모듈이 문제의 원인임을 발견했습니다.

root@server:/# pam_tally2
Login           Failures  Latest    failure     From
username           53    06/05/18   16:53:42    xxx.xxx.xxx.xxx

문제의 원인을 찾았지만 동작을 이해할 수 없습니다. 어쩌면 pam 모듈에 뭔가 잘못 구성된 것이 있을 수도 있습니다. 내가 입력할 때마다 sudo su(성공 여부) 실패가 pam_tally2. 올바른 비밀번호를 성공적으로 입력하면 실패 시도가 증가하는 이유를 모르겠지만 그렇습니다. 아래 예.

pam_tally2
Login           Failures  Latest    failure     From
username           0    06/05/18   16:53:42    xxx.xxx.xxx.xxx

username@server:/ sudo su
[sudo] password for username:
root@server:/#

pam_tally2
Login           Failures  Latest    failure     From
username           1    06/05/18   16:54:03    xxx.xxx.xxx.xxx

sudo -s또는 를 사용 하면 sudo -i의 오류도 증가합니다 pam_tally2.

답변1

승인되지 않은 외부 사용자의 지속적인 로그인 시도가 있다고 말씀해 주셨는데요. 원치 않는 원격 로그인이 root귀하의 사용자 계정을 참조하려고 시도하는 경우 PAM 모듈이 둘 중 하나 또는 둘 다를 잠그고 있음 username을 의미할 수 있습니다 .pam_tally2

명령 을 실행하여 pam_tally2오류를 일으키는 원인을 확인하십시오. ( pam_tally2 --user=username --reset에서 블록을 재설정하려면 실행해야 할 수도 있습니다 username.

또는 이 문제 보고서pam_tally2는 /etc/ssh/sshd_config 파일에 "ChallengeResponseAuthentication yes"가 설정된 경우 좋은 비밀번호를 실패한 로그인 시도로 계산합니다.시나리오를 더 자세히 설명할 수 있습니다. (아직도 솔루션의 대체 소스를 찾기 위해 노력하고 있습니다.)


덧붙여서, Canonical의 모든 최선의 (그러나 잘못된) 노력에도 불구하고 어떤 용도로도 사용할 필요가 없습니다 sudo su. (이것은 "라고 말하는 것과 같습니다.나에게 루트를 줘? 알겠습니다. 감사합니다. 이제 나는 루트입니다. 루트가 되어야 합니다.".) sudo -s루트 쉘이나 sudo -i루트 로그인 쉘을 사용해 보십시오.

관련 정보