❀️ Nanny! Super detailed! Connect Linux virtual machine remotely! ❀️

  🎈 Author: Linux ape

🎈 Introduction: CSDN blog expert πŸ†οΌŒ C/C + +, interview, question brushing and algorithm. Please consult me, pay attention to me and chat privately if you have any questions!

🎈 Attention column: Linux technology   (high quality articles are constantly updated...) πŸš€

πŸ“ catalogue

✨ 1, Ubuntu

πŸ“’ 1.0 environment

πŸ“’ 1.1 installation of auxiliary software

πŸ“’ 1.2 start service

πŸ“’ 1.3 set the root password and modify the configuration

πŸ“’ 1.4 remote connection

✨ 2, CentOS

πŸ“’ 2.0 environment

πŸ“’ two point one   Set IP

πŸ“’ two point two   Remote connection

✨ 3, Remote connection tool

πŸ“’3.1Β XShell

πŸ“’3.2Β MobaXterm

πŸͺ 4, Summary

This article explains in detail the steps of remote connection to virtual machines, considering that more people use them   For Ubuntu and CentOS, this article explains these two operating systems respectively.

In fact, most desktop operating systems are based on Ubuntu, and many operating systems are based on CentOS. Therefore, if you know these two operating systems, you will basically understand the vast majority of cases.

✨ 1, Ubuntu

πŸ“’ 1.0 environment

The environment used is as follows:

linuxy@linuxy:~$ cat /proc/version
Linux version 5.8.0-50-generic (buildd@lgw01-amd64-030) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #56~20.04.1-Ubuntu SMP Mon Apr 12 21:46:35 UTC 2021
linuxy@linuxy:~$ 

πŸ“’ 1.1 installation of auxiliary software

Execute the following commands in sequence:

linuxy@linuxy:~$ sudo apt update // Update source

linuxy@linuxy:~$ sudo apt install net-tools // Install net tools and provide ifconfig command

linuxy@linuxy:~$ sudo apt install openssh-server // Install openssh server for SSH connection

The functions of the above three commands are: update source, install net tools, provide ifconfig command, and install openssh server for SSH connection.

πŸ“’ 1.2 start service

Execute the following commands in sequence:

linuxy@linuxy:~$ sudo systemctl enable ssh // Set startup

linuxy@linuxy:~$ sudo systemctl start ssh // Open service

The functions of the above two commands are: set the ssh service to start, and start the ssh service.

πŸ“’ 1.3 set the root password and modify the configuration

If you want to use root to log in remotely, execute the following command:

linuxy@linuxy:~$ sudo passwd root

linuxy@linuxy:~$ sudo sed -i '/#PermitRootLogin prohibit-password/a\PermitRootLogin yes' /etc/ssh/sshd_config

linuxy@linuxy:~$ sudo systemctl restart ssh

root remote login is not allowed on ubuntu by default. You need to modify the configuration and restart the ssh service after modification.

πŸ“’ 1.4 remote connection

Use the remote connection tool to connect. Next, connect through the Windows terminal.

Figure 1 remote connection

  The connection command format is ssh user name @ IP

Look at Part 3 for the remote connection tool.

✨ 2, CentOS

πŸ“’ 2.0 environment

The environment used is as follows:

ersion 4.18.0-80.el8.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.2.1 20180905 (Red Hat 8.2.1-3) (GCC)) #1 SMP Tue Jun 4 09:19:46 UTC 2019
[linuxy@localhost ~]$ 

πŸ“’ two point one   Set IP

[root@localhost ~]# sudo vim /etc/sysconfig/network-scripts/ifcfg-ens33

Modify ifcfg-ens33 ONBOOT=no to ONBOOT=yes, and the file contents are as follows

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=dhcp

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

IPV6_ADDR_GEN_MODE=stable-privacy

NAME=ens33

UUID=98a1093c-5c53-402f-ab07-60b29071b1df

DEVICE=ens33

ONBOOT=yes

Reload configuration file

[root@localhost ~]# nmcli c reload

Execute ifconfig to check the IP address. At this time, there will be an IP address, as shown below:

  ping the IP of the virtual machine under Windows, as shown below:

  Show connected.

πŸ“’ two point two   Remote connection

Use the remote connection tool to connect. Next, connect through the Windows terminal.

  The connection command format is ssh user name @ IP

Look at Part 3 for the remote connection tool.

✨ 3, Remote connection tool

πŸ“’3.1Β XShell

Xshell is a very powerful SSH client. It supports SSH1, SSH2 and TELNET protocol of Microsoft Windows platform. Xshell can be used to access servers under different remote systems under the windows interface, so as to control the server locally and remotely.

Figure 1 XShell

Β Β 

πŸ“’3.2Β MobaXterm

MobaXterm is a powerful SSH client that provides important remote network tools (SSH, X11, RDP, VNC, FTP, MOSH, etc.) and Unix commands (bash, ls, cat, sed, grep, awk, rsync, etc.) for Windows desktop.

Figure 2 MobaXterm

Β Β 

πŸͺ 4, Summary

Remote connection is mainly used to configure the network, install dependent packages and connect with remote tools. Remote connection is connected in the form of SSH.

⭐ Haowen recommendation ⭐

Git development essential. gitignore detailed explanation! [suggested collection]

The most popular Linux is it, and Ubuntu ranks sixth?

Linux is 30 years old, you know?

What kind of experience is it after reading "advanced programming in UNIX Environment" on the subway!

  🎈 Welcome to praise πŸ‘, Collection ⭐, Leaving a message. πŸ’¬

Tags: Linux

Posted on Sat, 18 Sep 2021 08:08:34 -0400 by echoninja