A server address: 192.168.1.200, hereinafter referred to as A
B server address: 192.168.1.201, hereinafter referred to as B
1. Generate a key pair in A:
ssh-keygen -t rsa -P ""
2. Copy A's public key (id_rsa.pub) to B
Here is an example of copying to the root user home directory of B:
3. Login B
Copy the id_rsa.pub content of A to the authorized_keys file in the .ssh directory
cd /root
cat id_rsa.pub >> .ssh/authorized_keys
4. At this time, if you log in to B with SSH in A or copy files to B, you will not need a password.
ssh [email protected]
scp abc.txt [email protected]:/root
To realize B password-free login to A, the operation method is the same. In B, use ssh-keygen to generate an ssh key pair, copy the public key to A, and A copies B's public key to the authorized_keys file in the .ssh directory. That's it.