Linux Enable SSH Key Login - Big Cat Will Be Cute

Linux Enabling SSH Key Login

Author: Big cats can also be cute Classification: Classification: Reprint log Published on: 2018-12-31 0:00 ė 22944 views six 0 comments

Hello everyone, Big Cat. I wish you a happy New Year's Day in advance, A friend asked me how to log in with a key in Linux, but I couldn't draw a specific conclusion before because I didn't have practice, and sent it to my friend after Baidu. Today, Big Cat will teach you how to use the key instead of the password to log in to Linux. The key points are as follows: VMware8 putty puttygen WinSCP The operating systems are Centos7.5 Ubuntu16.04.3LTS

First, enter the. ssh directory under the user directory of the Linux system. Prompt: If the. ssh directory does not exist, you can create it manually
The root user is /root/.ssh
Ordinary users are /Home/Your user name/. ssh

After logging in to the system, it is found that the. ssh directory does not exist. Create a

 Click to enlarge the picture

Then comes the command to generate the key
Ssh keygen - t rsa - b Key length
If parameter b is not added, 256 bit rsa encryption is used by default
If you do not use the password, please press Enter to skip

 Click to enlarge the picture

After generating the key, the directory will generate the following files

 Click to enlarge the picture

modify /etc/ssh/sshd_config
RSA Authentication yes # Enable RSA authentication Since Centos does not exist in the system, it needs to be added manually
PubkeyAuthentication yes # Whether to use public key authentication
AuthorizedKeysFile. ssh/authorized_keys # Save location of public key
PasswordAuthentication no # Disable login using password authentication

 Click to enlarge the picture

Enter the key directory and execute the following command
touch authorized_keys


cat id_rsa.pub >> authorized_keys


chmod 600 authorized_keys


 Click to enlarge the picture

Download the key file locally using winscp

 Click to enlarge the picture

For versions before CentOS 7 and ubuntu, please execute:
sudo service sshd restart
CentOS 7, please execute:
systemctl restart sshd.service

 Click to enlarge the picture

Then use puttygen to convert the key

Open Private Key

 Click to enlarge the picture

Save Private Key

 Click to enlarge the picture

Then test login

 Click to enlarge the picture


 Click to enlarge the picture


 Click to enlarge the picture

Then you can see that the newly created private key successfully logs in to the server

centos

 Click to enlarge the picture

ubuntu

 Click to enlarge the picture

This is the end of the tutorial. If you still don't understand, please contact Big Cat for help


This article is from Big Cat Huimeng. Please indicate the source and the corresponding link when reprinting.

zero
After reading this article, your mood is:
 
nausea
anger
Strongly like
be moved
pass by
boring
Lei Gui
follow

Comment

E-mail addresses will not be made public. Required items have been used * tagging