码迷,mamicode.com
首页 > 系统相关 > 详细

linux主机之间建立ssh信任关系

时间:2017-02-24 19:50:33      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:linux

需求:

    hostA 要免密码ssh登入 hostB,即建立ssh信任关系


实施:

    1、hostA:在~/.ssh,创建ssh密钥对

            执行命令 ssh-keygen -t rsa (要求输入的位置直接回车),默认生成密钥对文件 id_rsa 和 id_rsa.pub 

    2、hostB:在~/.ssh,修改信任文件authorized_keys

            把 hostA 的公钥文件 id_rsa.pub 追加到 hostB 的~/.ssh/authorized_keys文件中


验证:

    hostA 要免密码ssh登入 hostB


小结:

    我要免密码登陆你,把我的公钥给你


可能发生的意外和解决办法:

    建立了信任关系,但是仍然无法通过信任关系登陆,检查:

        1、文件权限是否正确(实践证明这点是有用的)

            SSH doesn’t like it if your home or ~/.ssh directories have group write permissions. Your home directory should be writable only by you, ~/.ssh should be 700, and authorized_keys should be 600

            You can also get around this by adding StrictModes off to your ssh_config file, but I’d advise against it - fixing permissions is the way to Go

        2、确保sshd服务已开启

        3、跟ssh配置文件有关/etc/ssh/sshd_config(未经实践)

            据说可以修改ssh服务的认证方法 ,从密码认证改为公钥认证,请自行百度“/etc/ssh/sshd_config 信任关系



本文出自 “哈度” 博客,请务必保留此出处http://hadoooo.blog.51cto.com/12526479/1901045

linux主机之间建立ssh信任关系

标签:linux

原文地址:http://hadoooo.blog.51cto.com/12526479/1901045

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!