• linux 互信不生效


    1.  操作系统版本

    1)操作系统

     cat /etc/issue
    cat /etc/issue
    CentOS release 6.6 (Final)
    Kernel on an m

     cat /proc/version
    cat /proc/version

    Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014

    2. 问题描述

    1) 配置互信

    172.172.230.210 下执行(root用户)

    ssh-keygen -t rsa
    ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.172.230.211

    172.172.230.211 下执行(root用户)

    ssh-keygen -t rsa
    ssh-copy-id -i /root/.ssh/id_rsa.pub root@172.172.230.210

    2) 验证互信是否生效

    在172.172.230.210上执行

    ssh 172.172.230.211 hostname >>执行成功无需提供密码

    在172.172.230.211 上执行

    1. ssh 172.172.230.210 hostname  
    2. root@172.172.230.210's password:   

    ##但是在172.172.230.211上执行ssh连接172.172.230.210 时提示需要密码,互信没有生效。

    3. 问题分析

    3.1 可能会导致互信产生问题的原因有如下三个

    1) 目录权限,文件权限

    ##以root用户为例,root目录,.ssh目录 除了目录的属主可以具有write权限以外,属组和其他用户都不能对root目录和.ssh目录具有write权限(root用户配置互信时,秘钥文件保存路径为/root/.ssh/),否则其他主机在使用互信登录该主机时,依然会提示需要输入密码。authorized_keys文件权限应该为600

    2) seliux

    1. vi /etc/selinux/config   
    2.   
    3. # This file controls the state of SELinux on the system.  
    4. SELINUX=disabled  
    5. #     enforcing - SELinux security policy is enforced.  
    6. #     permissive - SELinux prints warnings instead of enforcing.  
    7. #     disabled - No SELinux policy is loaded.  
    8. SELINUX=disabled  
    9. SELINUXTYPE= can take one of these two values:  
    10. #     targeted - Targeted processes are protected,  
    11. #     mls - Multi Level Security protection.  
    12. SELINUXTYPE=targeted  

    ##selinux 设置为disabled

    3) iptables

    1. service iptables status  
    2. iptables: Firewall is not running.  

    ##iptables服务没有起,所以不是这个原因

    3.2 查看172.172.230.210 的/var/log/secure日志

      通过上面的分析我们大致可以判断应该是目录权限导致互信不生效了,接一下来我们查看一下/var/log/secure日志中有什么信息:

    1. May 17 17:17:15 shaofei-test-mysql-01 sshd[24719]: Failed password for root from 172.172.230.211 port 17890 ssh2  
    2. May 17 17:17:17 shaofei-test-mysql-01 sshd[24719]: Failed password for root from 172.172.230.211 port 17890 ssh2  
    3. May 17 17:17:17 shaofei-test-mysql-01 sshd[24721]: Connection closed by 172.172.230.211  
    4. May 17 18:08:26 shaofei-test-mysql-01 sshd[25004]: Authentication refused: bad ownership or modes for directory /root  
    5. May 17 18:08:26 shaofei-test-mysql-01 sshd[25004]: Authentication refused: bad ownership or modes for directory /root  

    ##日志中很清楚的反应了因为/root目录权限的问题,导致互信失败。后来发现172.172.230.210 上的/root 目录的权限为777,修改为700或者750问题解决

      注意172.172.230.210上目录权限有问题会导致其他主机在使用免密码登录该服务器的时候又问题,但是如果其他机器的目录和文件权限没有问题,并且配置了互信,那么172.172.230.210使用免密码登录其他服务器是不会有问题的

    4. 解决方案

       修改/root目录权限为 700 或者750,或者755

    http://blog.csdn.net/shaochenshuo/article/details/51438354

  • 相关阅读:
    【leetcode】Spiral Matrix
    【leetcode】Permutations
    【leetcode】Search Insert Position
    【leetcode】Search for a Range
    文件名对目标文件夹可能过长
    协同过滤和简单SVD优化
    奇异值分解(SVD)和简单图像压缩
    PCA数据降维
    FP-growth高效频繁项集发现
    关联挖掘和Aprioir算法
  • 原文地址:https://www.cnblogs.com/seasonzone/p/6097987.html
Copyright © 2020-2023  润新知