1. Generate public and private keys for the host that requires secret – free login

# cd /root
# ssh-keygen -t rsa
Copy the code

-t RSA can be omitted. By default, rsa keys are generated

Note: A message is displayed after the command is executed. After the command is executed, enter enter three times. Two files, id_rsa and id_rsa.pub, are generated in the. SSH directory of the current user.

Copy the public key to the ~/.ssh/authorized_keys file on the logged-in host

Run the ssh-copy-id command to copy data directly

#SSH - copy - id - I ~ /. SSH/id_rsa pub [email protected]
Copy the code

After this command is executed, the public key file of the login host is automatically appended to the authorized_keys file in the specified user root. SSH directory on the target host. The process is fully automatic and very convenient.

At this point, the authorized_keys file can be seen in the root/. SSH path of the landing machine:

Iii. Create Jenkins credentials

Upload the login private key (ID_RSA) file to Jenkins

Reference article: Linux Key Login principles and SSH Using Key to Achieve Password-free login