원격 시스템 10.10.10.1에는 “user”라는 사용자의 비밀번호 “asdFGH12″가 있습니다. 비밀번호 “asdFGH12dasdkjlkjasdus”또는 “asdFGH12″문자열 뒤에 다른 문자를 입력해도 로그인 할 수 있습니다.
$ ssh -v 10.10.10.1
OpenSSH_5.2p1 FreeBSD-20090522, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
debug1: Connection established.
debug1: identity file /home/user/.ssh/identity type 0
debug1: identity file /home/user/.ssh/id_rsa type -1
debug1: identity file /home/user/.ssh/id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_4.1
debug1: match: OpenSSH_4.1 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.2p1 FreeBSD-20090522
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '10.10.10.1' is known and matches the RSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:58
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /home/user/.ssh/id_dsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /home/user/.ssh/id_rsa
debug1: Next authentication method: keyboard-interactive
Password:
debug1: Authentication succeeded (keyboard-interactive).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
Warning: untrusted X11 forwarding setup failed: xauth key data not generated
Warning: No xauth data; using fake authentication data for X11 forwarding.
debug1: Requesting X11 forwarding with authentication spoofing.
Last login: Tue Apr 23 14:30:59 2013 from 10.10.10.2
Have a lot of fun...
user@server:~>
이것은 (확실한) SSH 서버 버전의 알려진 동작입니까?
답변
이것은 SSH 서버의 제한 사항이 아니며 서버의 비밀번호 해시 알고리즘의 제한 사항입니다.
Unix에서 비밀번호를 해시 할 때 crypt()
함수가 호출됩니다. 이것은 많은 백엔드 중 하나를 사용할 수 있으며 DES를 사용하고 있거나 다른 제한 알고리즘을 사용할 수 있습니다 (이 경우 서버에서 DES를 사용한다고 가정합니다). DES는 일반적으로 현대 운영 체제에서 기본적으로 사용되지 않습니다. 특히 암호 제한 및 유효성 검사가 8 바이트로 제한되어 있기 때문입니다.
즉, 비밀번호가 “foobarbaz”로 설정되면 일반적으로 경고 나 통지없이 “foobarba”가됩니다. 유효성 검사에도 동일한 제한이 적용됩니다. 즉 “foobarbaz”, “foobarba”및 “foobarbazqux”는 모두이 특정 사례에 대해 유효성이 검사됩니다.
답변
OS가 DES 암호 암호화를 사용하고 있다고 생각합니다.이 암호는 최대 8 자만 지원합니다.
/server/361591/ssh-accepts-only-the-half-password
에서 man crypt(3)
GNU 확장
이 기능의 glibc2 버전에는 다음과 같은 추가 기능이 있습니다. salt가 3 개의 문자 “$ 1 $”로 시작하고 그 뒤에 최대 8 자이고 선택적으로 “$”로 끝나는 문자열 인 경우 DES 시스템을 사용하는 대신 glibc crypt 함수는 MD5 기반 알고리즘을 사용합니다. 최대 34 바이트, 즉 “$ 1 $ <string> $”를 출력합니다. 여기서 “<string>”은 salt에서 “$ 1 $”다음에 오는 최대 8자를 나타내고 세트 [a–zA에서 선택한 22 바이트를 나타냅니다. –Z0–9./].
전체 키는 여기에서 중요합니다 (처음 8 바이트 대신).
pam 설정을 확인하여 MD5 또는 DES를 사용 중인지 확인할 수 있습니다.
% egrep "password.*pam_unix.so" /etc/pam.d/system-auth
password sufficient pam_unix.so md5 shadow nis nullok try_first_pass use_authtok
이 명령으로 시스템에서 사용중인 해싱 기능을 확인할 수도 있습니다.
% authconfig --test | grep hashing
password hashing algorithm is md5
이 시스템 /etc/shadow
파일 에서 MD5를 사용하고 있음을 알 수 있습니다.
root:$1$<DELETED PASSWORD HASH>:14245:0:99999:7:::
/etc/shadow
각 유형의 해싱에 대한 코드는 다음 과 같습니다.
- $ 1 – MD5
- $ 2 – 복어
- $ 2a – eksblowfish
- $ 5 – SHA-256
- $ 6 – SHA-512
이 명령으로 시스템을 재구성 할 수 있습니다 :
% authconfig --passalgo=sha512 --update
기존 비밀번호를 다시 생성해야합니다.이 명령을 사용하여 다음에 로그인 할 때 사용자가 비밀번호를 재설정하도록 할 수 있습니다.
% chage -d 0 userName