三台服务器无需密码相互访问
Posted lmgsanm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了三台服务器无需密码相互访问相关的知识,希望对你有一定的参考价值。
主机IP:192.168.0.155、192.168.0.156、192.168.0.158
- 修改sshd_config配置
vim /etc/ssh/sshd_config
AuthorizedKeysFile .ssh/authorized_keys
- 创建ssh密钥
ssh-keygen
id_rsa是生成的本地密钥
id_rsa.pub是生成的共享密钥,用于对方安全访问本机使用
- 拷贝共享密钥并重启服务
分别将两台机子的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== [email protected]
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== [email protected]
192.168.0.155的authorized_keys
vim /root/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAt0KgNM1nsxSve3ZYSIFt/CdnnaAaiB/8wvuCDX22/Z99vIWqBjI6+pYu4Rtfl8bHc2DWl9FfIKEM/+xcqYiHyhyHdQz62q9CQyf8l7W73q/RDWR+RqyXx6OrIwpJ/YtZV9nLC1wstXehGCD3SctfiKRh4Se9d1oUWpnr6Np9iucyXXqn6NGWywniwwQzPoYkEGVZYC9rmszwmPSlFQdvN0MHYvfAmq93Jq0ecBE7YsEVYzeVQANq7jIPMaFCRH21LcSaix1sSbmE29r1zQ7Xu6N2UXR7YMeLUMMICjx+aB7BtdlNiroKb5kas9Qx8x5sDeLcaRKai8251L/Qic7orw== [email protected]
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0bFNPHJx2mjdeZ3XdJxO07rclCIkEo8WQv6i3vw5pOCLWGFNTNv/eCNHqlEMX2r+Zbt/M15zCGBuaZ1TeCnln9NdIn+X3CGrGXtLhRO21p0EkSISJQPb6YT7Nl8Lb2vePpL/ajcSVK0hIerSsERXhGmZX5hTdNcLbEI/Ua+T2MwaeSPJEU17BLL+dYUW164YhfmZC3kvzL/A/NqhyWeZwB72gzybURFXpcbC7jmBSt0hVDfhobSptyUtp38ucMhVOXKdOs3OuAb5yPlv6uPCTUkXGuH7A29eEyQOEjRaVSF3Ay8e6z/tjnVyoIvmvfbuTmMdozJxAVp2L0WKCiWEfw== [email protected]
以上是关于三台服务器无需密码相互访问的主要内容,如果未能解决你的问题,请参考以下文章