介绍
介绍
如果两个服务器都是自己的机器,相互之间登录,复制文件等等操作每次都需要输入密码,确实麻烦
跟福哥来学习通过配置SSH信任实现主机之间免密操作
教程
配置SSH信任
在A机器操作
建立密钥
[root@localhost]# ssh-keygen -t rsa [root@localhost]# ls ~/.ssh/id_rsa* id_rsa id_rsa.pub
查看公钥
[root@localhost]# cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAADCAQABAAABAQDYXXQoe6Q0YUBgQWRtdgqSccd0rx3fOphZE5gsciq8m/OmuCQoVTonrGKjCUu2OlxJRUmBofnV4MC4MLN8QEjhitELmLK77sntGjGcDZvyqNHn1eUHWYlK7zowDvBTq74NWp24Dy6D21hvAGvyQ6p3o+G1/OLi5zlNyCmZYCtNW5YXA35yzcd8xnOc3IfD/Up4/n0wVBs3DyNy581Yj1NyJ6l+qWrXQ3P298Qh5AmpUJWtPR7vpfDI7vYMzbpj/xnbyiU5ZjyYQ03xZN/LQV4NZ7trxtrCFq2BjtB5Et0KfSZtaCgRcmp7LGqp3aAIwXHP4Dsa2W8J/iTBID1USN7N root@test
在B机器操作
授权公钥
[root@localhost]# echo "ssh-rsa AAAAB3NzaC1yc2EAAADCAQABAAABAQDYXXQoe6Q0YUBgQWRtdgqSccd0rx3fOphZE5gsciq8m/OmuCQoVTonrGKjCUu2OlxJRUmBofnV4MC4MLN8QEjhitELmLK77sntGjGcDZvyqNHn1eUHWYlK7zowDvBTq74NWp24Dy6D21hvAGvyQ6p3o+G1/OLi5zlNyCmZYCtNW5YXA35yzcd8xnOc3IfD/Up4/n0wVBs3DyNy581Yj1NyJ6l+qWrXQ3P298Qh5AmpUJWtPR7vpfDI7vYMzbpj/xnbyiU5ZjyYQ03xZN/LQV4NZ7trxtrCFq2BjtB5Et0KfSZtaCgRcmp7LGqp3aAIwXHP4Dsa2W8J/iTBID1USN7N root@test" >> ~/.ssh/authorized_keys [root@localhost]# chmod 0700 ~/.ssh [root@localhost]# chmod 0600 ~/.ssh/authorized_keys
这样通过A机器去操作B机器的时候就不需要密码了
结论
结论就是一句话:谁拿了我的公钥,我就可以随便进谁家