ssh-keygen -t rsa
-- 三台分别执行 ssh-keygen -t rsa 不用输入密码,
一路回车就行
#slave1 cp ~/.ssh/id_rsa.pub ~/.ssh/slave1_id_rsa.pub
scp ~/.ssh/slave1_id_rsa.pub master:~/.ssh/
#slave2 cp ~/.ssh/id_rsa.pub ~/.ssh/slave2_id_rsa.pub
scp ~/.ssh/slave2_id_rsa.pub master:~/.ssh/
#master cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/slave1_id_rsa.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/slave2_id_rsa.pub >> ~/.ssh/authorized_kyes
这样master就能免密访问slave,比如ansible的master操作。
如果要让slave免密访问master就把authorized_kyes拷贝到slave
scp ~/.ssh/authorized_keys slave1:~/.ssh
scp ~/.ssh/authorized_keys slave2:~/.ssh