2.ssh免密配置

是我毒奶了

视频链接:https://www.bilibili.com/video/BV1aM4y137pA/

设置主机名&&关闭防火墙

hostnamectl set-hostname 主机名
bash #刷新

 

systemctl stop firewalld.service #关闭防火墙
systemctl disable firewalld.service #永久关闭防火墙
systemctl status firewalld #查看防火墙状态
 
#记录各台主机ip,host映射,重新链接就能看到公网IP
vim /etc/hosts
#把复制的ip 主机名 粘贴进来,本机ip设置为内网ip,服务器的话其他主机ip设置为公网ip

SSH主从免密

ssh-keygen #回车回车
cd /root/.ssh/
ls #设置.key文件权限

 

cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
ssh localhost #判断是否成功
yes
exit

 

scp master:/root/.ssh/id_rsa.pub /root #主节点秘钥拷贝到从节点
ls / root/ #看看有没有
cat /root/id_rsa.pub >> authorized_keys #继续追加
(这一步一定要回到authorized_keys的目录,不然会无效)
ssh slave1 #主节点操作,连上就说明连接成功了
 
 

SSH从主免密

scp slave1:/root/.ssh/id_rsa.pub /root
ls /root/ #还是确定有无
cat /root/id_rsa.pub >> authorized_keys

 

#重复上述节点操作
scp slave2:/root/.ssh/id_rsa.pub /root
cat /root/id_rsa.pub >> authorized_keys

 

ssh master #拿从节点验证一下
exit
原文地址:https://www.cnblogs.com/thx2199/p/15319328.html