This document is for record only
1. Generate a key (all machines must be executed)
ssh-keygen -t rsa
2. View the generated ".ssh" folder in the user's root directory, and use commands to view hidden files
ls -al
3. View the generated files under ".ssh"
- authorized_keys: Store the public key for remote password-free login, and mainly use this file to record the public keys of multiple machines (the file does not exist initially) *
- id_rsa: The generated private key file *
- id_rsa.pub: Generated public key file*
- know_hosts: List of known host public keys*
4. Copy the public key to the same machine
- method one:
Three machines will copy the public key to the first machine, and the three machines will execute the command:
ssh-copy-id cdh01
At this time, the authorized_keys file will be generated in the .ssh folder of cdh01
- Way two:
Manual copy and paste
1. Copy the public keys of the three servers to the first server scp id_rsa.pub root@cdh01:$PWD
2. Add the public keys of the three servers to the authorization list. If ssh /authorized_keys does not exist, create it manually: cat id_rsa. pub >> authorized_keys
3. The permissions of the .ssh directory must be 700, chmod 700 .ssh
4. The permissions of the authorized list authorized_keys must be 600, chmod 600 authorized_keys
5. Copy authorized_keys authentication to other machines
Copy the public key authorization list file configured on the first machine to other machines and execute the following command
scp /root/.ssh/authorized_keys cdh02:/root/.ssh
scp /root/.ssh/authorized_keys cdh03:/root/.ssh