Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Key login of SSH

2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Key login of SSH

1. Background introduction

Usually we log on to the remote terminal by entering the account number and password, is there any other way to play? The answer is: of course there is! Here is a way to log in to ssh through a key.

Tool preparation: one computer (recommended win10), one virtual machine (recommended vmware workstation11), ssh login tool (xshell,securecrt,putty, recommended xshell), linux system (redhat,centos,debian,ubuntu, recommended centos7.3).

Let's get started.

two。 Experimental procedure

Suppose you have logged in to the linux terminal through the ssh tool.

(1) generate public and private keys

Ssh-keygen-t rsa

Enter file in which to save the key (/ root/.ssh/id_rsa): # # enter directly using the default path

Created directory'/ root/.ssh'.

Enter passphrase (empty for no passphrase): # # enter password

Enter same passphrase again: # # repeat password

Two files are generated under the / root/.ssh/ directory, with id_rsa as the private key and id_rsa.pub as the public key. The private key is downloaded to the local computer and saved properly, while the public key can be made public at will.

(2) download the private key to windows

Sz / root/.ssh/id_rsa

If not, install the package lrzsz (yum install-y lrzsz)

(3) Import public key

Cat / root/.ssh/id_rsa.pub > > / root/.ssh/authorized_keys

(4) change the SSH configuration file

Modify the configuration file / etc/ssh/sshd_config of SSH and find the following three lines:

# RSAAuthentication yes

# PubkeyAuthentication yes

# AuthorizedKeysFile .ssh / authorized_keys

Remove the previous # and save it. Restart the SSH service, run the command: systemctl restart sshd

(5) xshell configuration (see figure)

1. Create a new session

two。 Select authentication method

3. Import private key

4. Enter the password set by yourself

5. Determine the user key

6. Enter password

7. Select the appropriate session

8. Successful landing

(6) disable SSH password login

Modify the configuration file / etc/ssh/sshd_config of SSH to find the following line:

PasswordAuthentication yes

Modified to:

PasswordAuthentication no

Restart the SSH service and run the command:

Systemctl restart sshd

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report