SSH security for Linux, using key pair authentication

Source: Internet
Author: User
Tags asymmetric encryption

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.