YouTip LogoYouTip

Linux Remote Login

Linux is generally used as a server, and servers are typically placed in data centers. You cannot operate your Linux server directly in the data center. Therefore, we need to remotely log in to the Linux server to manage and maintain the system. Remote login functionality in Linux systems is implemented through the SSH service, with the default SSH service port being 22. On Windows systems, Linux remote login clients include SecureCRT, Putty, SSH Secure Shell, etc. This tutorial uses Putty as an example to log in to a remote server. Putty download address: [https://www.putty.org/](https://www.putty.org/) If you have downloaded Putty, double-click putty.exe, and the following window will pop up. !(#) In the box below Host Name (or IP address), enter the IP address of the remote server you want to log in to (you can check the server IP using the ifconfig command), then press Enter. !(#) At this point, it prompts us to enter the username for login. !(#) Enter root, press Enter, then enter the password, and you will be logged into the remote Linux system. !(#) * * * ## Remote Login to Linux Using Key Authentication SSH stands for Secure Shell, developed by the IETF's Network Working Group. SSH is a secure protocol built on the application layer and transport layer. First, use the tool PUTTYGEN.EXE to generate a key pair. After opening the tool PUTTYGEN.EXE, it will look like the following: !(#) This tool can generate keys in three formats: SSH-1(RSA), SSH-2(RSA), SSH-2(DSA). We use the default format, which is SSH-2(RSA). "Number of bits in a generated key" refers to the size of the generated key. The larger this value, the more complex the generated key and the higher the security. Here, we enter 2048. !(#) Then click Generate to start generating the key pair: !(#) Note that during this process, you need to move the mouse randomly; otherwise, the progress bar will not move. !(#) At this point, the key pair has been generated. You can enter a passphrase for your key (in the Key Passphrase field) or leave it blank. Then click Save public key to save the public key, and click Save private key to save the private key. It is recommended to store them in a secure location to prevent others from accessing them and to avoid accidental deletion. Next, we need to set up on the remote Linux host. 1) Create the directory /root/.ssh and set permissions [root@localhost ~]# mkdir /root/.ssh The mkdir command is used to create directories. It will be explained in detail later; for now, just understand its basic use. [root@localhost ~]# chmod 700 /root/.ssh The chmod command is used to modify file attribute permissions. It will be explained in detail later. 2) Create the file /root/.ssh/authorized_keys [root@localhost ~]# vim /root/.ssh/authorized_keys The vim command is used to edit text files. It will also be explained in detail in subsequent chapters. 3) Open the public key file you just generated. It is recommended to use WordPad to open it for better readability. Copy all content from the line starting with AAAA to the line "---- END SSH2 PUBLIC KEY ----", and paste it into the /root/.ssh/authorized_keys file. Ensure all characters are on a single line. (You can first copy the content to Notepad, edit it into a single line, and then paste it into the file.) Here, let me briefly explain how to paste: After opening the file with vim, the file does not exist, so vim will automatically create it. Press the letter "i", then simultaneously press Shift + Insert to paste (or right-click with the mouse), provided the content has already been copied to the clipboard. After pasting, move the cursor to the beginning of the line and type **ssh-rsa**, then press the spacebar. Then press ESC, type :wq, and press Enter to save. The format is as shown in the following image: !(#) 4) Then set the PuTTY options. Click SSH –> Auth on the left side of the window, click Browse… on the right side of the window to select the private key you just generated, then click Open. At this point, enter root, and you can log in without entering a password. !(#) If you set a Key Passphrase earlier, it will prompt you to enter the password. For greater security, it is recommended to set a Key Passphrase.
← Linux User ManageLinux Forget Password β†’