1 week 4th Lesson Single user mode rescue mode clone virtual machine Linux login to each other

Source: Internet
Author: User

One, single user mode

Purpose: The root password is forgotten and the password is reset with a single user, if grub is not encrypted

1. Restart the virtual machine, and when the System boot menu appears, press the up and down arrows on the keyboard to move the menu to the first item

650) this.width=650; "Src=" Https://s3.51cto.com/oss/201710/19/06aa67120dcb2b8274c27ac7c6957082.png-wh_500x0-wm_3 -wmp_4-s_3977212968.png "title=" 1.1.png "alt=" 06aa67120dcb2b8274c27ac7c6957082.png-wh_ "/>

Press "E" key, enter the editor, use the UP and DOWN ARROW keys, move the cursor to "linux16" this line, and then use the left and RIGHT arrow keys to move the cursor to "RO" place

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201710/19/a6a84d2fe77e741b21fba450611119fb.png-wh_500x0-wm_3 -wmp_4-s_4021628203.png "title=" 1.2.png "alt=" A6a84d2fe77e741b21fba450611119fb.png-wh_ "/>

Replace "RO" with "RW init=/sysroot/bin/sh" note the space, then press "CTRL" and "X" at the same time

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/4edf0b841d99cf6eb7dbf370429d0412.png-wh_500x0-wm_3 -wmp_4-s_3753139033.png "title=" 1.3.png "alt=" 4edf0b841d99cf6eb7dbf370429d0412.png-wh_ "/>

system boot into single user mode, enter "chroot/sysroot/", then enter "lang=en"

(Note case, this setting avoids garbled characters)

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/dd3ab370b31ab09a18a3ed1fb45ebaed.png-wh_500x0-wm_3 -wmp_4-s_3026361019.png "style=" Float:none; "title=" 1.4.png "alt=" Dd3ab370b31ab09a18a3ed1fb45ebaed.png-wh_ "/>

Enter "passwd" to reset the password, then enter "Touch/.autorelabel" and restart the VM via the "virtual Machine" menu.

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/ba0c88c160dd9eaac9eff6ab31362da5.png-wh_500x0-wm_3 -wmp_4-s_1740819015.png "style=" Float:none; "title=" 1.5.png "alt=" Ba0c88c160dd9eaac9eff6ab31362da5.png-wh_ "/>

Restart time may be longer than usual, after the landing screen, you can use the new password login.


Second, rescue mode

Use: System damage cannot be entered to repair, or root password forgotten, but can not be reset through single user mode, etc.

This assumes the root password is forgotten and is reset using rescue mode

1. Load the system installation CD to the virtual machine, click on the "Wrench" button on the main screen of the virtual machine, click "Optical Drive" in the pop-up menu, select the System installation CD (previously selected), tick the check box of the connection directly, then click "Show All" to return to "settings" main interface

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/11f8a4c9293b999446c4795b0c05e90e.png-wh_500x0-wm_3 -wmp_4-s_1576994166.png "style=" Float:none; "title=" 1.6.png "alt=" 11f8a4c9293b999446c4795b0c05e90e.png-wh_ "/>

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/c8e3d3a1949a754e596bb180caac1b0a.png-wh_500x0-wm_3 -wmp_4-s_1148348337.png "style=" Float:none; "title=" 1.7.png "alt=" C8e3d3a1949a754e596bb180caac1b0a.png-wh_ "/>

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/3d5935ef3d7a9cf507a0f455358a5520.png-wh_500x0-wm_3 -wmp_4-s_3126277968.png "style=" Float:none; "title=" 1.8.png "alt=" 3d5935ef3d7a9cf507a0f455358a5520.png-wh_ "/>

The machine starts from the CD, enters the CD main interface, selects the third item "Troubleshooting" Enter, selects "Rescue a CentOS Linux system" carriage return, opens enters "The rescue mode", appears after the choice menu enters "1", the carriage return

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/a355df4dbbb2435408e9ff01eeab56e1.png-wh_500x0-wm_3 -wmp_4-s_512743577.png "style=" Float:none; "title=" 1.9.png "alt=" A355df4dbbb2435408e9ff01eeab56e1.png-wh_ "/>

Enter the rescue mode again.

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/e9c57daeddb8120217808c73773dc3de.png-wh_500x0-wm_3 -wmp_4-s_1005189442.png "style=" Float:none; "title=" 1.91.png "alt=" E9c57daeddb8120217808c73773dc3de.png-wh_ "/>

According to the prompt, the original system has been loaded into the/mnt/sysimage, enter "chroot/mnt/sysimage" switch to the directory

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/1a55c5a2dac81f3e6e28fab375fc24bc.png-wh_500x0-wm_3 -wmp_4-s_3898570348.png "style=" Float:none; "title=" 1.92.png "alt=" 1a55c5a2dac81f3e6e28fab375fc24bc.png-wh_ "/>

As above, the prompt has been changed from "sh-4.2#" to "bash-4.2#" and the "passwd" command follows the prompts to reset the password and restarts the virtual machine via the "virtual machine" menu after completion (remember to cancel booting from the CD). Then log in with your new password.


Third, cloning virtual machine

Use: Eliminate the repetitive installation system, quickly generate more than one virtual machine

1. Turn off the virtual machine power, tap virtual Machine, and then click Create Full Clone

650) this.width=650; "Src=" Https://s4.51cto.com/oss/201710/19/aecb0de603c269de5368df3f33326915.png-wh_500x0-wm_3 -wmp_4-s_1884757773.png "style=" Float:none; "title=" 1.93.png "alt=" Aecb0de603c269de5368df3f33326915.png-wh_ "/>

Popup Clone VM Save dialog, enter the name of the new machine, click "Save" to start cloning

650) this.width=650; "Src=" Https://s3.51cto.com/oss/201710/19/ebc93593a510de567e1a70e7071fbe49.png-wh_500x0-wm_3 -wmp_4-s_4246890818.png "style=" Float:none; "title=" 1.94.png "alt=" Ebc93593a510de567e1a70e7071fbe49.png-wh_ "/>

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201710/19/d0ee6633ec7400ea3fe94d0140ec7222.png-wh_500x0-wm_3 -wmp_4-s_4138840302.png "style=" Float:none; "title=" 1.95.png "alt=" D0ee6633ec7400ea3fe94d0140ec7222.png-wh_ "/>

Cloning complete, the desktop immediately more than a "virtual machine"

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201710/19/75cdcade3af0b61d19cfe5297376f71e.png-wh_500x0-wm_3 -wmp_4-s_3242762528.png "style=" Float:none; "title=" 1.96.png "alt=" 75cdcade3af0b61d19cfe5297376f71e.png-wh_ "/>


Four, the Linux machine between each other landing

There are two ways that Linux machines can log in to each other.

One is to enter the account password via SSH, and the other is to log in using the key


Test environment Preparation

Open the newly cloned machine, modify the machine's IP to avoid IP collisions, and remove the "UUID" of its network card,

Modify the machine name "Hostnamectl set-hostname centos702",

650) this.width=650; "Src=" Https://s1.51cto.com/oss/201710/19/0838dd2ef59806054355ee683c29701f.png-wh_500x0-wm_3 -wmp_4-s_4184255655.png "style=" Float:none; "title=" 1.97.png "alt=" 0838dd2ef59806054355ee683c29701f.png-wh_ "/>

After confirming the network connection, open another machine and make the same changes (IP is not changed)

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/c6677fe17612e76a29d2b41209dd598e.png-wh_500x0-wm_3 -wmp_4-s_124965086.png "style=" Float:none; "title=" 1.98.png "alt=" C6677fe17612e76a29d2b41209dd598e.png-wh_ "/>


1.SSH Login

Prepare: Connect two servers separately using Remote Tools connection

Select a machine (choose 702 here), enter the command in the format "ssh-p port [email protected]", follow the prompts for "yes" enter, and then enter centos701 root password to log on successfully

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/d3fd69793e8f403b8567d74ae16534d6.png-wh_500x0-wm_3 -wmp_4-s_560263064.png "style=" Float:none; "title=" 1.99.png "alt=" D3fd69793e8f403b8567d74ae16534d6.png-wh_ "/>


Because the port defaults to 22 and the centos702 current user is "root", the command can be simplified to "ssh 172.16.107.158"

(The language is described as: using the SSH protocol default port 22, use the root identity to log on to 172.16.107.158)

Note that after the login succeeds, the change before the left prompt

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/ae8a2c066a41a5a41970286decd1385d.png-wh_500x0-wm_3 -wmp_4-s_822261170.png "style=" Float:none; "title=" 1.991.png "alt=" Ae8a2c066a41a5a41970286decd1385d.png-wh_ "/>

The same operation can also be connected to 702 on 701.

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/a0aa6ee5c0957a57066999e8ec803dac.png-wh_500x0-wm_3 -wmp_4-s_2871260282.png "style=" Float:none; "title=" 1.992.png "alt=" A0aa6ee5c0957a57066999e8ec803dac.png-wh_ "/ >


2. Key Login

Choose a machine, here 701

Enter "Ssh-keygen" at the command line, start generating the key, enter OK to save, set the password for the key

Follow the prompts to find the public and private keys under the/root/.ssh folder

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/b9e733a1fc0be0395f5ec0e06f560a5c.png-wh_500x0-wm_3 -wmp_4-s_1364544115.png "style=" Float:none; "title=" 1.993.png "alt=" B9e733a1fc0be0395f5ec0e06f560a5c.png-wh_ "/ >

Copy the public key in Id_rsa.pub to 702 "/root/.ssh/authorized_keys" and Remember to run "Getenforce 0" in 702

650) this.width=650; "Src=" Https://s2.51cto.com/oss/201710/19/bb29eb24b1ee410e5aee8dbd29b233a8.png-wh_500x0-wm_3 -wmp_4-s_63177485.png "style=" Float:none; "title=" 1.994.png "alt=" Bb29eb24b1ee410e5aee8dbd29b233a8.png-wh_ "/>

Then go back to the 701 Remote window, enter SSH 172.16.107.159, enter the key password, you can complete to 702 login

650) this.width=650; "Src=" Https://s5.51cto.com/oss/201710/19/f419bc0a098cf7afff2b8caa66cc8e60.png-wh_500x0-wm_3 -wmp_4-s_2866151022.png "style=" Float:none; "title=" 1.995.png "alt=" F419bc0a098cf7afff2b8caa66cc8e60.png-wh_ "/ >

In the same vein, the public key generated on 702 is placed in the "/root/.ssh/authorized_keys" of 701, which completes the mutual encryption-free landing


1 week 4th Lesson Single user mode rescue mode clone virtual machine Linux login to each other

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.