zl程序教程

您现在的位置是:首页 >  大数据

当前栏目

配置主机之间的信任关系

配置 关系 之间 主机 信任
2023-09-14 08:59:49 时间

下面是用root用户执行配置的,也可以切换到其他用户去做这个配置,那么跳转的时候就 ssh username@192.168.1.13即可 


1.生成各个主机自己的秘钥文件 
主机a和主机b相同操作 
[root@sfxbdb04 ~]# cd .ssh 
[root@sfxbdb04 .ssh]# ls -lrt 
total 12 
-rw-r--r-- 1 root root  857 Sep 13 14:26 authorized_keys 
-rw-r--r-- 1 root root 4725 Oct 29 16:29 known_hosts 

[root@sfxbdb04 .ssh]# rm -f authorized_keys 
[root@sfxbdb04 .ssh]# rm -f known_hosts 
[root@sfxbdb04 .ssh]# ssh-keygen -t dsa     ---有的是用rsa,一路回车即可 
Generating public/private dsa key pair. 
Enter file in which to save the key (/root/.ssh/id_dsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_dsa. 
Your public key has been saved in /root/.ssh/id_dsa.pub. 
The key fingerprint is: 
34:8a:16:02:25:dc:20:ae:ee:95:b1:32:99:e7:3b:6c root@sfxbdb04.sf-express.com 

[root@sfxbdb04 .ssh]# ls -lrt 
total 8 
-rw-r--r-- 1 root root 618 Oct 30 16:55 id_dsa.pub 
-rw------- 1 root root 668 Oct 30 16:55 id_dsa 
[root@sfxbdb04 .ssh]# cat id_dsa.pub authorized_keys 

2.把主机a的authorized_keys传到另一台主机b相同目录 
scp authorized_keys root@192.168.1.14:/root/.ssh 

3.主机b将自身的秘钥写入authorized_keys 
[root@sfxbdb04 .ssh]# ls -l 
total 12 
-rw-r--r-- 1 root root 1854 Oct 30 16:59 authorized_keys 
-rw------- 1 root root  668 Oct 30 16:55 id_dsa 
-rw-r--r-- 1 root root  618 Oct 30 16:55 id_dsa.pub 

cat id_dsa.pub authorized_keys 

4.查看 
cat -n authorized_keys 

5.再把这个传回去给主机a就可以了。 
scp authorized_keys root@192.168.1.13:/root/.ssh 

6.跳转测试(2台主机都能成功执行下面2个即成功) 
ssh 192.168.1.13 
ssh 192.168.1.14 

记得第一次需要yes一下 
为了在你的 Confluence 中与其他应用建立外部小工具,我们建议你在 2 个应用之间设置 OAuth 或者信任的应用连接关系。