码迷,mamicode.com
首页 > 其他好文 > 详细

配上ssh等效连接

时间:2020-01-17 10:08:07      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:authorize   home   解决   mysq   机器   不成功   sql   mod   date   

配置等效连接
host1 :192.168.216.150
host2 :192.168.216.151
host3 :192.168.216.152

A.配置 host1 与 host2 的等效连接
步骤1.host1:192.168.216.150
[mysql@host1]$ mkdir ~/.ssh
[mysql@host1]$ chmod 700 ~/.ssh
[mysql@host1]$ ssh-keygen -t rsa
[mysql@host1]$ ssh-keygen -t dsa


步骤2.host2:192.168.216.151
[mysql@host2]$ mkdir ~/.ssh
[mysql@host2]$ chmod 700 ~/.ssh
[mysql@host2]$ ssh-keygen -t rsa
[mysql@host2]$ ssh-keygen -t dsa


步骤3.host1:192.168.216.150
[mysql@host1]$cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[mysql@host1]$cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[mysql@host1]$ssh 192.168.216.151 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[mysql@host1]$ssh 192.168.216.151 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[mysql@host1]$scp ~/.ssh/authorized_keys 192.168.216.151:~/.ssh/authorized_keys


步骤4:
[mysql@host1]$ ssh 192.168.216.151 date
[mysql@host2]$ ssh 192.168.216.150 date

B.配置host1与host3的等效连接

1.host3
[mysql@host3]$ mkdir ~/.ssh
[mysql@host3]$ chmod 700 ~/.ssh
[mysql@host3]$ ssh-keygen -t rsa
[mysql@host3]$ ssh-keygen -t dsa

2.host1
[mysql@host1]$ssh 192.168.216.152 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[mysql@host1]$ssh 192.168.216.152 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[mysql@host1]$scp ~/.ssh/authorized_keys 192.168.216.152:~/.ssh/authorized_keys


B.配置host2与host3的等效连接
host2
[mysql@host1]$ssh 192.168.216.152 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[mysql@host1]$ssh 192.168.216.152 cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
[mysql@host1]$scp ~/.ssh/authorized_keys 192.168.216.152:~/.ssh/authorized_keys


偶尔有些机器上老是配置不成功,非要在root账号下配置。
解决办法(每台机器上root账号下执行):
在ssh用户的
cd /home/mysql/.ssh
chmod 710 authorized_keys

配上ssh等效连接

标签:authorize   home   解决   mysq   机器   不成功   sql   mod   date   

原文地址:https://www.cnblogs.com/hxlasky/p/12204180.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!