3 1)创建密钥对(所有node)
4 root@node1:~#ssh‐keygen‐trsa
5 Generatingpublic/privatersakeypair.
6 Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):
7 Createddirectory'/root/.ssh'.
8 Enterpassphrase(emptyfornopassphrase):
9 Entersamepassphraseagain:
10 Youridentificationhasbeensavedin/root/.ssh/id_rsa.
11 Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.
12 Thekeyfingerprintis:
13 SHA256:pSB0+TY8bLWi2ZUp+Qv8Gq3jralKK2pLVp3icf1jYXoroot@node1
14 Thekey'srandomartimageis:
15 +‐‐‐[RSA2048]‐‐‐‐+
16 |...|
17 |....|
18 |..+o.+|
19 |..o.%o=|
20 |++OSX|
21 |o+oB.o|
22 |o....E..|
23 |o....+=+|
24 |oo..o..o*+.|
25 +‐‐‐‐[SHA256]‐‐‐‐‐+
26
27 2)生成公钥文件
28 root@node1:~/.ssh#catid_rsa.pub>>authorized_keys
29 root@node1:~/.ssh#ls‐lh
30 总用量12K
31 ‐rw‐r‐‐r‐‐1rootroot3923月110:40authorized_keys
32 ‐rw‐‐‐‐‐‐‐1rootroot1.8K3月110:40id_rsa
33 ‐rw‐r‐‐r‐‐1rootroot3923月110:40id_rsa.pub
34 root@node1:~/.ssh#chmod600authorized_keys
35
36 3)将node2节点的公钥追加到authorized_keys
37 root@node2:~/.ssh#catauthorized_keys>1.txt
38 root@node2:~/.ssh#scpid_rsa.pubnode1:~/.ssh/1.txt
39 root@node1:~/.ssh#cat1.txt>>authorized_keys
40
41 4)查看ssh互信的公钥信息
42 root@node1:~/.ssh#catauthorized_keys
评论