新装系统root用户密码ssh无法登入,pubkey验证ssh登入OK,虽然不影响使用,只是比较纳闷为什么会这样。
背景情况:
1、新安装一台CentOS 7,没有下载最新的镜像文件,用的这个:CentOS-7.0-1406-x86_64-livecd.iso;
2、安装过程中没有创建其它用户,装好后root账号无法登入,有点纳闷,只好认为自己安装时输入两遍的密码记错了;
3、参考这里的方法重设了root密码:
http://www.tejasbarot.com/2014/08/06/rhel-7-centos-7-recovering-root-password/
此时本地登入OK,启动SSH服务,root远程SSH用密码方式无法登入,现象同密码输入错误,即输入账号、密码后,提示“Access Denied”。
/var/log/secure中ssh登入时看到的相关log如下(只是更改hostname、rhost、IP等信息):
May 27 08:38:03 MYHOST unix_chkpwd[6385]: password check failed for user (root)
May 27 08:38:03 MYHOST sshd[6383]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=xxx.xxx.xxx user=root
May 27 08:38:03 MYHOST sshd[6383]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root"
May 27 08:38:05 MYHOST sshd[6383]: Failed password for root from 172.28.xxx.xxx port 1511 ssh2
因为是新系统,并没有更改过sshd配置限制root登入,不过我还是确认了下,默认配置是这样:
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
还有密码验证也是yes:
PasswordAuthentication yes
我也试过将PermitRootLogin前面的#删掉,root同样无法登入,新建一个普通用户后,用此用户可以SSH密码方式登入,不过登入后 su - 切换root同样提示密码不对。
我也没有调整过系统的pam相关验证配置,搞不清楚怎么回事;
也尝试过将SElinux改为Permissive,状况一样。
目前是将新建用户加入wheel组,看了sudo默认配置wheel组可以执行所有命令;
同时将新建的普通用户和root都配置了pubkey方式登入,这样我还好,不过其他一些同事一直习惯用密码方式,所以密码无法登入的问题还是想查清楚。