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

Note 1 install, login CentOS7, single user mode, rescue mode, Linux machines log in to each other

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

Share

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

Create a virtual machine

Create a new virtual machine > typical > install the operating system later > linux (L) centOS64 bit > find a large disk from the location of the virtual machine name > set the disk size to 30g to save the virtual disk as a single file > finish

Install centOS7

Edit the virtual machine settings to find the image file on your computer in CD/DVD > turn on the virtual machine > select the second line CentOS Linux7 enter > choose language Chinese simplified Chinese > system installation location > check the standard disk > select below I want to configure partition > standard partition point + number > boot score 200m swap2048 (2 times the memory) (when your memory is less than 4G, you give 2% of the memory. Times greater than 4G, up to 8g) all the rest are given / > set password > complete

Configure ip

First use the dhclient command to get ip automatically

Then use the id add command to check and you will see that there is an ens33 network card in which the ip is automatically obtained.

These are all dynamic ip to be set to static.

Method: edit the configuration file of the network card ls / etc/sysconfig/entwork-scripts/ifcfg-ens33 can use the Tab key to fill the full-length command, but some are not useful, such as net, because there is more than one path that begins with him, we can install the Tab key twice, and he will show you below how to edit the file with the command vi / etc/sysconfig/network-scripts/ifcfg-ens33. Press the direction key to move press the I key to edit BOOTPROTO (a way to start) = dhcp (automatic acquisition) change dhcp to static (static) change ONBOOT=no no to yes or restart will not be loaded

IPADDR=192.168.118.129

NETMASK (subnet mask) = 255.255.255.0

GATEWAY (Gateway) = 192.168.118.2

DNS1=119.29.29.29 (generic) Press Esc to exit: wq Save

According to the edit virtual network editor in the menu bar, take a look at his subnet and subnet mask NAT setting and his gateway in it.

Start with centos7: restart with systemctl restart network.service

Previously used: service network restart

Ifconfig check the last ping www.aminglinux.com of the ip address

Network problem troubleshooting

Method 1: the NAT mode we use can switch the mode bridge mode.

The network adapter in the lower right corner of the point virtual machine is set to bridge mode.

Then get the ip command again: if dhclient is running, close it with dhclient-r

Get the ip again, and then ifconfig check the ip, and you will find that it has changed. If it hasn't changed, it means you haven't bridged successfully. You need to check the network segment that you bridged through your Windows, play cmd, and run ipconfig to check the local connection as it is set to the same network segment ping. When the Network is unreachable shows that there is something wrong with the network, check to see if your network card settings are all linked.

Method 2: open the virtual network editor to remove VMnet8 and re-add it to choose NAT mode. He will have a new subnet gateway ip.

At this time, ping will click on the gateway ping public network.

Command: routing-n can't even check the gateway, just edit the configuration file vi / etc/sysconfig/entwork-scripts/ifcfg-ens33 and change it.

Secret key authentication

The first step is to operate on puttygen.

The second step is to operate on the putty client

Mkdir / root/.ssh create a .ssh file

Chmod 700 / root/.ssh change permissions for .ssh

Vi / root/.ssh/authorized_keys to create and change the public key file, be sure to press an I key to enter edit mode before pasting the generated public key chain

Turn off the selinux Firewall:

Setenforce 0 close the protective wall

Finally, set putty > ssh > Auth > to load your saved private key.

Single user mode

Restart the client command:

Four methods: 1.reboot 2.init 6 3.shutdown-r now 4. Power supply-restart the client

Shutdown command: 1.init 0 2.poweroff

Press the direction key in the restart interface, select the first line, press the e key, (e means to edit)

When you come in, find the line that begins with linux16:

Change ro to rw init=/sysroot/bin/sh as shown below:

Press: press ctrl+x when the input is finished

Then there will be the / # interface, where you can type commands

Give the command:

Chroot / sysroot/ switched to the original system because it was just in a memory operating system

Cat / root/.ssh/authorized_keys

LANG=en definition language, change to English, otherwise there will be garbled.

Passwd root change password

Touch /. Autorelabel remember that you must type this at last, or you won't be able to log in to the system.

Reboot: power from the client

Rescue mode

Another way to change the toot password is available when Linux fails to function properly

Ls-1 / usr/lib/systemd/system/runlevel*target View 7 runlevels

Shutdown first > Edit Virtual Machine Settings > check if there is a link to check the iOS image at startup of CD/DVD (IDE) > right-click the virtual machine power > start to enter bios (in order to enable him to load the optical drive at startup) > enter the bios interface and select boot at the top > press +-set VD-ROM Drive to the top > press F10Eng yes to exit > Select the third line enter > select the second line enter (as shown below)

The next step is to choose 1 enter.

At enter, go to sh-4.2#, and then issue the command to change the password:

Chroot / mnt/sysimage

Password root change password

Click the small CD icon below to disconnect the devices in the network configuration > restart

Clone a virtual machine

Method: shutdown > Management > Clone > next > Select create Link Clone next > finish > Boot

Modify the ip address of the clone machine and delete > UUID > IPADDR > restart network service > production to see ip > ping to the public network

Modify the ip method to see note 1. Http://12922638.blog.51cto.com/12912638/1928001

Finally, change the names of the two virtual machines

Hostname View Hostname

Hostnamectl set-hostname * (hostname you want to change)

Restart

Linux machines log in to each other

Method: use 01 and 02 even with another machine first.

Enter the command: ssh *. * * (your own ip) enter the password

Command: W to see what terminals are connected to w (check system load)

Then use 02 and 01.

Ssh connects to port 22 by default

How to connect the specified port command: ssh-p * * root@ your own ip here * * indicates the specified port, for example: ssh-p 22 root@192.168.232.129

How to verify the key of two Linux:

Command: ssh-keygen > generate key pair > three enter and generate key pair > you can view the following directory command: ls / root/.ssh

How to put it on the other one and use the command:

Cat / root/.ssh/id_rsa.pub copy the following public key to another

Edit the configuration file on another machine: vi / root/.ssh/authoorized_keys paste in and save

Command: getenforce to see if selinux is open

Enforcing means to turn it on with the command: setenforce 0 temporarily off

Permissive means off.

Connect the ssh again.

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