有帖子说,要设置成下面那样。但我压根就没有密码啊。 ChallengeResponseAuthentication no PasswordAuthentication no UsePAM no
其实最大的问题是UsePAM的设置: # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. If this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. Depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no'. 我心想那就UsePAM no吧,但又看到有人说「设置问UsePAM no后无法通过key登陆。原来新建账户的时候没有给该账户设置密码,导致无法通过登陆。给账户设置一个密码后就可以通过key登陆了(因为是通过key登陆,所以建立账户没设置密码,但是UsePAM设置成no后,如果账户密码是空是无法通过key登陆的。)」。