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

How to realize remote login by Linux

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly shows you how to achieve remote login Linux, the content is easy to understand, I hope you can learn, after learning there will be a harvest, the following let the editor to take a look at it.

Linux is generally used as a server, and the server is generally placed in the computer room, you can not operate your Linux server in the computer room.

At this point, we need to log in remotely to the Linux server to manage and maintain the system.

In the Linux system, the remote login function is realized through ssh service, and the default ssh service port number is 22.

The Linux remote login clients on Window system include SecureCRT, Putty, SSH Secure Shell and so on. This paper takes Putty as an example to log in to the remote server.

Putty download address: http://www.putty.org/

If you downloaded putty, double-click putty.exe and pop up the following window.

Enter the remote server IP you want to log in to in the box below Host Name (or IP address) (you can view the server ip through the ifconfig command), and then enter.

At this point, we are prompted to enter the user name to log in.

Enter root, then enter, and then enter the password to log in to the remote linux system.

Remote login to linux using key authentication mechanism

SSH is an acronym for Secure Shell and was developed by IETF's Network working Group (Network Working Group).

SSH is a security protocol based on application layer and transport layer.

First use the tool PUTTYGEN.EXE to generate a key pair. After opening the tool PUTTYGEN.EXE, the following figure is shown:

This tool can generate three formats of key:SSH-1 (RSA) SSH-2 (RSA) SSH-2 (DSA), and we use the default format, SSH-2 (RSA). Number of bits in a generated key refers to the size of the generated key. The higher this number, the more complex the generated key and the higher the security. Here we write 2048.

Then click Generate to start generating the key pair:

Note that in this process, the mouse should move back and forth, otherwise the progress bar will not move.

At this point, the key pair has been generated. You can enter a password for your key, or you can leave it blank (at Key Passphrase). Then click Save public key to save the public key and Save private Key to save the private key. The author suggests that you put it in a safer place to prevent others from peeping and to prevent erroneous deletion. Next, it's time to set it up on the remote linux host.

1) create directory / root/.ssh and set permissions

The [root@localhost ~] # mkdir / root/.ssh mkdir command is used to create a directory, which will be described in detail later. You can only learn about it for the time being.

The [root@localhost ~] # chmod 700 / root/.ssh chmod command is used to modify file attribute permissions, which will be described in more detail later.

2) create a file / root/.ssh/authorized_keys

The [root@localhost ~] # vim / root/.ssh/authorized_keys vim command is a command for editing a text file, which is also described in detail in subsequent chapters.

3) Open the public key file just generated, and it is recommended to use WordPad to open it, so that it looks more comfortable. Copy everything from the beginning of AAAA to the "- END SSH2 PUBLIC KEY -" line, paste it into the / root/.ssh/authorized_keys file, and make sure all the characters are on one line. You can copy the copied content to notepad, then edit it into a line and paste it into the file.

Here is a brief introduction to how to paste. After opening that file with vim, the file does not exist, so vim will be created automatically. Click the letter "I" and press shift + Insert at the same time to paste (or right-click), as long as it has been copied to the clipboard. After pasting, move the cursor to the front of the line, type ssh-rsa, and then press the space. Press ESC, then type the colon wq that is: wq and it will be saved. The format is as follows:

4) set the putty option again, click SSh-> Auth on the left side of the window, and click Browse on the right side of the window. Select the private key you just generated, click Open, and type root at this time, and you can log in without entering the password.

If you set Key Passphrase earlier, you will be prompted for your password at this time. It is recommended that you set up a Key Passphrase for more security.

This is about how Linux implements remote login. If you have learned knowledge or skills, you can share it for more people to see.

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

Servers

Wechat

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

12
Report