ssh 免密登录 ssh-keygen
ssh-keygen -t rsa
-- 三台分别执行 ssh-keygen -t rsa 不用输入密码,
一路回车就行
#master cat ~/.ssh/id_rsa.pub >> ~/.ssh/master_id_rsa.pub
scp ~/.ssh/master_id_rsa.pub slave1:~/.ssh/
scp ~/.ssh/master_id_rsa.pub slave2:~/.ssh/
#slave1 cat ~/.ssh/master_id_rsa.pub >> ~/.ssh/authorized_keys
#slave2 cat ~/.ssh/master_id_rsa.pub >> ~/.ssh/authorized_keys
这样master就能免密访问slave,比如ansible的master操作。
########如果要让slave免密访问master就把slave1_id_rsa.pub slave2_id_rsa.pub拷贝到master
ssh-copy-id hostname 也行,不过这样要输入密码
原理:
known_hosts |
记录ssh访问过计算机的公钥(public key) |
id_rsa |
生成的私钥 |
id_rsa.pub |
生成的公钥 |
authorized_keys |
存放授权过的无密登录服务器公钥 |