解决ssh public key登录弹出密码输入提示

os : centos 6.x

因磁盘空间不够,将/home整个mount到一块大硬盘上,之后发现不能用普通帐号ssh登录了。新加的用户也不能使用ssh登录。root帐号一切正常。初步认定是挂载/home目录时导致的权限问题。

调试步骤:

  1. use root account to execute
    chmod 755 /home
  2. 新建用户test,在.ssh下添加authorized_keys,加入本机的public key。
    useradd test
    chmod 700 /home/test
    su test
    cd
    mkdir .ssh
    chmod 700 .ssh
    add your public key to .ssh/authorized_keys
    chmod 600 .ssh/authorized_keys
  3. 用ssh -vvvT [email protected]尝试登录,查看/var/log/secure
    ....
    Jun 18 16:32:05 test sshd[1019]: debug1: trying public key file /home/test/.ssh/authorized_keys
    Jun 18 16:32:05 test sshd[1019]: debug1: restore_uid: 0/0
    Jun 18 16:32:05 test sshd[1019]: Failed publickey for test from xx.xx.xx.xx port 36222 ssh2
    好吧,登录失败。。。
    查看/var/log/audit/audit.log,好吧,更悲剧,没有记录。。。(该问题没搞定)
  4. 查看selinux
    执行getenforce,状态为Enforcing
    setenforce 0试试,再ssh -vvvT [email protected],成功了!那肯定和selinux有关了。把selinux改回来先:setenforce 1
  5. maybe home directory is badly labeled,恢复一下/home目录标签试试
    restorecon -R -v /home
    再试试ssh -vvvT [email protected],成功了!搞定

猜你喜欢

转载自avoidxx.iteye.com/blog/1888798