Login Authentication object: Local user account in server
Login Authentication Method:
Password verification: Check whether the user name, password matches
Key pair Validation: Checks the client's private key and server public key for matching
# Vim/etc/ssh/sshd_config
Passwordauthentication Yes//password verification
Pubkeyauthentication Yes//key pair Verification
Authorizedkeysfile. Ssh/authorized_keys//Key Save place
# systemctl Restart Ssh.service
Building the SSH system for key pair validation:
First step: Create a key pair (created on the client, including the private key and public key after creation, forming a key pair)
Private key file: Id_rsa
Public key file: id_rsa.pub
# ssh-keygen-t RSA
Set Key Save location
Set the key password
"Private key permissions are: 600
Public key permissions are: 644
This encryption method is asymmetric encryption, the private key file must not be public "
Step two: Upload the public key file to the server
Step three: Import the public key file
The following command uploads and imports the second and third-step compositions together:
# Ssh-copy-id [Email protected]_ip_address
Example:
Before importing the public key file, use the Guest user to switch to the user001 User:
[Email protected]:~$ ssh [email protected]
[email protected] ' s password:
Start uploading and importing the public key file:
Use Guest user to upload and import public key file to user001 user, upload and import successfully, use Guest user to switch to user001 user, without user001 password to log in to user001 (if guest user creates password when creating key pair, Enter the key password):
[Email protected]:~$ ssh-copy-id [email protected]
Enter the User01 password
Upload and import successful, in the user001 user's ~/.ssh directory has a file Authorized_keys, that is, the upload and import of the public key file
Use the Guest user to switch to user001 without a user001 password to log in
[Email protected]:~$ ssh [email protected]
Enter passphrase for key '/home/guest/.ssh/id_rsa ':
SSH security for Linux, using key pair authentication