ssh认证失败

zaghost 2012-10-21 03:53:26
从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

这是什么原因?有什么办法可以解决这个问题?
...全文
320 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zaghost 2012-10-23
  • 打赏
  • 举报
回复
自己顶三下
zaghost 2012-10-22
  • 打赏
  • 举报
回复
自己顶二下
zaghost 2012-10-21
  • 打赏
  • 举报
回复
自己顶一下

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧