sshd在最小的Linux上:“无效的用户root密码失败”

我试图在最小的Fedora安装上启动SSH服务器。 我的意思是非常小:由diskimage-builder ramdisk builder生成的。 它甚至没有用户(缺less/etc/passwd等)。

所以,现在我试图在这样的系统上运行sshd。 在构build过程中,我从最小的(最小)系统复制/etc/ { passwdgroupshadow }。 我还预生成主机密钥和sshd_config

 PermitRootLogin yes UsePAM no UseDNS no UsePrivilegeSeparation no PasswordAuthentication yes HostKey /etc/ssh/ssh_host_key HostKey /etc/ssh/ssh_host_rsa_key HostKey /etc/ssh/ssh_host_dsa_key HostKey /etc/ssh/ssh_host_ecdsa_key 

( 完整脚本 )。 在ramdisk中,我通过chpasswd设置了root密码,然后启动SSHd

 /sbin/sshd -p $SSH_PORT 

(现在的SSH_PORT是22,默认是一个)。 在ramdisk启动并报告之后,我尝试login。在这里,乐趣开始:

 debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: password [email protected]'s password: debug1: Authentications that can continue: publickey,password,keyboard-interactive Permission denied, please try again. [email protected]'s password: 

在我看到的服务器上的ssh日志

 debug1: userauth-request for user root service ssh-connection method password Could not get shadow information for NOUSER Failed password for invalid user root from 192.0.2.1 port 38734 ssh2 

所以,尽pipe我尝试了一切,用户“ root ”仍然无效。 任何想法都表示赞赏。

也许你没有在默认的sshd_config文件中看到这个评论?

 # WARNING: 'UsePAM no' is not supported in Fedora and may cause several # problems. 

在Fedora和Red Hat上,你必须启用PAMauthentication。

我想你很久以前肯定已经解决了你的问题了?

我有相同types的设置,但在Debian,而不是Fedora,最小的Linux没有PAM等,并偶然发现这个问题。 谷歌没有什么帮助,下载开放的SSH源后,我发现,在没有PAM的情况下,sshd在authentication过程中使用了glibc函数getpwnam() 。 这个函数毫无疑问是超级通用的,在任何types的环境中都是有用的,但是如果没有安装libnss_files.so.* ,它不会检查/etc/passwd和朋友。

添加这个库到我的最小的linux修复了我的问题。 我很想知道你的情况的原因?