码迷,mamicode.com
首页 > 其他好文 > 详细

三台服务器无需密码相互访问

时间:2016-05-17 13:01:08      阅读:216      评论:0      收藏:0      [点我收藏+]

标签:

主机IP:192.168.0.155、192.168.0.156、192.168.0.158

  1. 修改sshd_config配置

vim /etc/ssh/sshd_config

AuthorizedKeysFile      .ssh/authorized_keys

 

  1. 创建ssh密钥

 

ssh-keygen

 

 

 

id_rsa是生成的本地密钥

id_rsa.pub是生成的共享密钥,用于对方安全访问本机使用

  1. 拷贝共享密钥并重启服务

 

分别将两台机子的id_rsa.pub里面的内容拷贝到另外一台机子的authorized_keys文件中,重启sshd服务即可

192.168.0.156的id_rsa.pub

vim /root/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAt0KgNM1nsxSve3ZYSIFt/CdnnaAaiB/8wvuCDX22/Z99vIWqBjI6+pYu4Rtfl8bHc2DWl9FfIKEM/+xcqYiHyhyHdQz62q9CQyf8l7W73q/RDWR+RqyXx6OrIwpJ/YtZV9nLC1wstXehGCD3SctfiKRh4Se9d1oUWpnr6Np9iucyXXqn6NGWywniwwQzPoYkEGVZYC9rmszwmPSlFQdvN0MHYvfAmq93Jq0ecBE7YsEVYzeVQANq7jIPMaFCRH21LcSaix1sSbmE29r1zQ7Xu6N2UXR7YMeLUMMICjx+aB7BtdlNiroKb5kas9Qx8x5sDeLcaRKai8251L/Qic7orw== root@localhost.localdomain

 

192.168.0.158的id_rsa.pub

vim /root/.ssh/id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0bFNPHJx2mjdeZ3XdJxO07rclCIkEo8WQv6i3vw5pOCLWGFNTNv/eCNHqlEMX2r+Zbt/M15zCGBuaZ1TeCnln9NdIn+X3CGrGXtLhRO21p0EkSISJQPb6YT7Nl8Lb2vePpL/ajcSVK0hIerSsERXhGmZX5hTdNcLbEI/Ua+T2MwaeSPJEU17BLL+dYUW164YhfmZC3kvzL/A/NqhyWeZwB72gzybURFXpcbC7jmBSt0hVDfhobSptyUtp38ucMhVOXKdOs3OuAb5yPlv6uPCTUkXGuH7A29eEyQOEjRaVSF3Ay8e6z/tjnVyoIvmvfbuTmMdozJxAVp2L0WKCiWEfw== root@localhost.localdomain

 

192.168.0.155的authorized_keys

vim /root/.ssh/authorized_keys

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAt0KgNM1nsxSve3ZYSIFt/CdnnaAaiB/8wvuCDX22/Z99vIWqBjI6+pYu4Rtfl8bHc2DWl9FfIKEM/+xcqYiHyhyHdQz62q9CQyf8l7W73q/RDWR+RqyXx6OrIwpJ/YtZV9nLC1wstXehGCD3SctfiKRh4Se9d1oUWpnr6Np9iucyXXqn6NGWywniwwQzPoYkEGVZYC9rmszwmPSlFQdvN0MHYvfAmq93Jq0ecBE7YsEVYzeVQANq7jIPMaFCRH21LcSaix1sSbmE29r1zQ7Xu6N2UXR7YMeLUMMICjx+aB7BtdlNiroKb5kas9Qx8x5sDeLcaRKai8251L/Qic7orw== root@localhost.localdomain

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0bFNPHJx2mjdeZ3XdJxO07rclCIkEo8WQv6i3vw5pOCLWGFNTNv/eCNHqlEMX2r+Zbt/M15zCGBuaZ1TeCnln9NdIn+X3CGrGXtLhRO21p0EkSISJQPb6YT7Nl8Lb2vePpL/ajcSVK0hIerSsERXhGmZX5hTdNcLbEI/Ua+T2MwaeSPJEU17BLL+dYUW164YhfmZC3kvzL/A/NqhyWeZwB72gzybURFXpcbC7jmBSt0hVDfhobSptyUtp38ucMhVOXKdOs3OuAb5yPlv6uPCTUkXGuH7A29eEyQOEjRaVSF3Ay8e6z/tjnVyoIvmvfbuTmMdozJxAVp2L0WKCiWEfw== root@localhost.localdomain

 

三台服务器无需密码相互访问

标签:

原文地址:http://www.cnblogs.com/lmgsanm/p/5500842.html

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