ssh认证失败
从openssh-3.0.1的源码编译得到的sshd来做ssh服务器
但是客户端登录的时候,一直显示Access denied
看了一下源码,用的是auth-passwd.c的auth_password()来认证的,
int
auth_password(Authctxt *authctxt, const char *password)
{
.....
.....
.....
if (pw_password[0] != '\0')
salt = pw_password;
else
salt = "xx";
#ifdef HAVE_MD5_PASSWORDS
if (is_md5_salt(salt))
encrypted_password = md5_crypt(password, salt);
else
encrypted_password = crypt(password, salt);
#else /* HAVE_MD5_PASSWORDS */
# ifdef __hpux
if (iscomsec())
encrypted_password = bigcrypt(password, salt);
else
encrypted_password = crypt(password, salt);
# else
encrypted_password = crypt(password, salt);
# endif /* __hpux */
#endif /* HAVE_MD5_PASSWORDS */
printf("######### password=%s\n", password); //1
printf("######### encrypted_password=%s\n", encrypted_password); //2
printf("######### pw_password=%s\n", pw_password); //3
/* Authentication is accepted if the encrypted passwords are identical. */
return (strcmp(encrypted_password, pw_password) == 0);
}
1,2,3是我加的debug代码,
password是客户端输入的明文密码,
encrypted_password是加密后的密码
pw_password是shadow中的加密密码
1处显示的密码是正确的
2,3的输出的是
######### encrypted_password=$1nXOGo2.oW.g
######### pw_password=$1$dEHJ6Yxh$eSdTa7pW6Pk0WKYd1eKiZ/
encrypted_password和pw_password不一致所以认证失败
我发现加密密码是用crypt()来加密,而不是bigcrypt或md5_crypt
这是什么原因?有什么办法可以解决这个问题?