SSH Public Key login is more secure than password login due to easy disclosure of password password. SSH can easily use asymmetric encryption technology to contract two machines, the steps are as follows:
First step local machine generated key pair
directive: Ssh-keygen
Function: The public key (Id_rsa.pub) and the private key (ID_RSA) are generated locally (~/.ssh/), where the private key is used by the machine and cannot be compromised. The public key is provided to the remote server and appended to the other's public key file (~/.ssh/authorized_keys).
Ssh-keygen "'
In this way, two files Id_rsa.pub and Id_rsa will appear in the local directory ~/.ssh/.
The second step is to copy the public key to the remote server
directive: Ssh-copy-id
Function: Copy the local ~/.ssh/rsa.pub to the remote server and append to the ~/.ssh/authorized_keys file. This step can also be done through the SCP directive.
ssh-copy- ID [email protected]
You can log on to the remote server to confirm that the contents of the locally generated rsa.pub are included in the ~/.ssh/authorized_keys file.
Part three log on to the remote server
SSH [Email protected]
Other
Additional configuration information/etc/ssh/sshd_config
[Linux] SSH Public Key Login