2_3 linux 配置 ssh 免密码登录

1  在每个 CentOS 上设置其它  的hosts

192.168.31.187 eshop-cache01
192.168.31.xxx eshop-cache02
192.168.31.xxx eshop-cache03
192.168.31.xxx eshop-cache04

2 生成本机的公钥

ssh-keygen -t rsa   

 生成本机的公钥,过程中不断敲回车即可,ssh-keygen命令默认会将公钥放在/root/.ssh目录下

cd /root/.ssh
cp id_rsa.pub authorized_keys

cat  authorized_keys

公钥复制到本地authorized_keys文件,此时shh  连接就不用密码

3 配置三台机器互相之间ssh 免密码登录

将本机的公钥复制指定机器的authorized_keys文件中

ssh-copy-id -i hostname

将其它的公钥复制本机的authorized_keys,本机拥有所有公钥,在将authorized_keys复制到其它机器

scp authorized_keys hostname:/root/.ssh  

4 测试


ssh eshop-cache01
ssh eshop-cache02
ssh eshop-cache03
ssh eshop-cache04

发布了4 篇原创文章 · 获赞 0 · 访问量 25

猜你喜欢

转载自blog.csdn.net/world6968/article/details/94793589