Configure trust relationships between hosts



The following is to use the root user to perform the configuration, or you can switch to other users to do this configuration, then when jumping, just ssh [email protected]


1. Generate each host's own key file
Host a and host b are the same Operation
[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 ---Some use rsa, press Enter all the way to
Generate 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 [email protected]

[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. Transfer the authorized_keys of host a to another host b in the same directory
scp authorized_keys root@ 192.168.1.14:/root/.ssh

3. Host b writes its own key to 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. Check
cat -n authorized_keys

5. Send this back to host a.
scp authorized_keys [email protected]:/root/.ssh

6. Jump test (two hosts can successfully execute the following two successfully)
ssh 192.168.1.13
ssh 192.168.1.14

Remember to need yes for the first time

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326861385&siteId=291194637