Chinaunix首页 | 论坛 | 博客
  • 博客访问: 644591
  • 博文数量: 98
  • 博客积分: 3145
  • 博客等级: 中校
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-15 12:52
文章分类
文章存档

2021年(1)

2020年(1)

2016年(8)

2015年(3)

2014年(1)

2013年(5)

2012年(4)

2011年(9)

2010年(12)

2009年(42)

2008年(12)

我的朋友

分类: LINUX

2016-07-28 11:16:00

故障说明:
  今天同事反馈有一台服务器的普通账号配置好了authorized_keys仍旧无法登录,检查了key和配置的authorized_keys文件都没有发现问题,之后又使用ssh-copy-id拷贝了一遍key,仍旧无法登录。
故障排查:
  1.先检查了下id_rsa.pub文件,并在另外一台服务器上配置,登录没有问题,所以排查key本身的问题。
  2.使用ssh -v 检查登录过程,发现key登录失败之后跳转为密码登录,过程如下:
        OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
        debug1: Reading configuration data /etc/ssh/ssh_config
        debug1: Applying options for *
        debug1: Connecting to x.x.x.x [x.x.x.x] port 22.
        debug1: Connection established.
        debug1: identity file /home/zeus/.ssh/identity type -1
        debug1: identity file /home/zeus/.ssh/identity-cert type -1
        debug1: identity file /home/zeus/.ssh/id_rsa type 1
        debug1: identity file /home/zeus/.ssh/id_rsa-cert type -1
        debug1: identity file /home/zeus/.ssh/id_dsa type -1
        debug1: identity file /home/zeus/.ssh/id_dsa-cert type -1
        debug1: identity file /home/zeus/.ssh/id_ecdsa type -1
        debug1: identity file /home/zeus/.ssh/id_ecdsa-cert type -1
        debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
        debug1: match: OpenSSH_5.3 pat OpenSSH*
        debug1: Enabling compatibility mode for protocol 2.0
        debug1: Local version string SSH-2.0-OpenSSH_5.3
        debug1: SSH2_MSG_KEXINIT sent
        debug1: SSH2_MSG_KEXINIT received
        debug1: kex: server->client aes128-ctr hmac-md5 none
        debug1: kex: client->server aes128-ctr hmac-md5 none
        debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
        debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
        debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
        debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
        debug1: Host 'x.x.x.x' is known and matches the RSA host key.
        debug1: Found key in /home/zeus/.ssh/known_hosts:1
        debug1: ssh_rsa_verify: signature correct
        debug1: SSH2_MSG_NEWKEYS sent
        debug1: expecting SSH2_MSG_NEWKEYS
        debug1: SSH2_MSG_NEWKEYS received
        debug1: SSH2_MSG_SERVICE_REQUEST sent
        debug1: SSH2_MSG_SERVICE_ACCEPT received
        debug1: Authentications that can continue: publickey,password
        debug1: Next authentication method: publickey
        debug1: Trying private key: /home/zeus/.ssh/identity
        debug1: Offering public key: /home/zeus/.ssh/id_rsa
        debug1: Authentications that can continue: publickey,password
        debug1: Trying private key: /home/zeus/.ssh/id_dsa
        debug1: Trying private key: /home/zeus/.ssh/id_ecdsa
        debug1: Next authentication method: password
   3.检查服务器的secure日志,发现以下信息:
      sshd[20485]: Authentication refused: bad ownership or modes for directory /home/zeus
     从日志看说明/home/zeus目录的权限设置的有问题,导致无法正常使用key认证。

   4.检查文件权限
      通过检查发现文件权限信息如下:
            drwxrwxr-x  10 zeus         mall-midware 4.0K Jul 28 10:19 zeus
      目前权限为771,这个不符合publickey的安全要求,所以使用chmod g-w修改目前权限变成751
           drwxr-xr-x  10 zeus         mall-midware 4.0K Jul 28 10:19 zeus
   5.重新登录测试
       问题解决
备注:
   publickey登录对文件和目录的权限推荐:
      ~/.ssh                            700
      ~/.ssh/authorized_keys    600
      ~                                   g-w,o-w

阅读(5243) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~