In Linux, password-based logon and key-based logon are prohibited.

Source: Internet
Author: User

Use Putty to Generate Keys and log on
According to the principle of public key authentication (see the description below), either party can make the key pair, and the authentication can be successful as long as the authenticated party has the public key information of the authenticated party.
Here, we will first log on to the Linux server using putty on Windows as an example. Therefore, this key pair is made by putty.
Before proceeding, make sure that you have downloaded the entire putty package:
These tools include putty, puttygen, pscp, plink, and pagent.
1. Use puttygen to create a key

Start the puttygen tool. to be compatible with the OpenSSH key, select "SSH2 RSA ":



Click the generate button and move the mouse in the blank area to obtain sufficient random data for the key generation:



※During this period, move the mouse until the progress bar is full.

The following window is displayed:



Where:
Key Note: The key validity is not affected, but it can be used as a reference for distinguishing other keys;
Two key passwords
Then, click Save private key.
If the key password is not entered, a warning is displayed:

Enter the Private Key File Name:

※The public key information can be retained locally. puttygen can obtain it from the private key, which is not used for verification.


2. Copy Public Key Information
Public Key Information:

Copy the information to a specific file on the Linux Server :~ /. Ssh/authroized_keys
"~" The main directory of the corresponding user. take root as an example.
If the. Ssh directory does not exist, create it and write the public key information to the file:
# Mkdir ~ /. SSH
# Chmod 700 ~ /. SSH
# Vi ~ /. Ssh/authorized_keys
# Chmod 644 ~ /. Ssh/authorized_keys
※Note: the permission of files and directories must be the user to be authenticated, and the permission must be 0644, that is, prohibit others from writing information to the file. (Otherwise, some interested people write their own public keys here, and they can also enter without a password)
Because umask is usually 0022 or 0002, use chown and chmod to change it to the corresponding permission.

4. Use Putty to log on with a key
Perform some simple configuration on Putty to log on to the Linux server with the key.
Select ssh-Authenticate and select the private key file you just saved.


Click Open.



Key Authentication-Based Configuration
# Vi/etc/ssh/sshd_config
Passwordauthentication no // password-based login prohibited
Pubkeyauthentication Yes // allow key-Based Access
#/Etc/init. d/sshd reload

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.