Single-user mode rescue mode clone virtual machine Linux machines log in to each other

Source: Internet
Author: User

One, single user mode
Forgot root password:
Method One: Use single-user mode
Linux restart command: Reboot, init 6, Shutdown-r now
Linux shutdown command: Init 0, Poweroff
Virtual machine Power on restart press the arrow key to select, select the first, press the E key to enter the following interface, press the DOWN ARROW key to find the mark

Modify RO to RW and add a string: init=/sysroot/bin/sh (Note: RO means read-only, rw means read-write), add these, press Ctrl+x

Switching system: chroot/sysroot/, so log on to the original operating system, and then change the password, direct input passwd root press ENTER, and then enter a new password, after the new password to perform an important step, enter:
Touch/.autorelable (remember: Do not perform this step to log on the system), after completing the above steps, click on the power reboot OK
(The above must be done on the physical machine, remote past operation is not)
Second, rescue mode
Use disc boot to modify the system root password.
Check the Linux CENTOS6 system for the 7 levels (0-6) command that corresponds to the CENTOS7 system operation:
Ls-l/usr/lib/systemd/system/runlevel Target
[Email protected] ~]# ls-l/usr/lib/systemd/system/runlevel
Target
lrwxrwxrwx. 1 root root 23:59/usr/lib/systemd/system/runlevel0.target-poweroff.target//0 level, shutdown
lrwxrwxrwx. 1 root root 23:59/usr/lib/systemd/system/runlevel1.target-Rescue.target//1 level, single user mode
lrwxrwxrwx. 1 root root 23:59/usr/lib/systemd/system/runlevel2.target-Multi-user.target//2 level, multi-user mode
lrwxrwxrwx. 1 root root 23:59/usr/lib/systemd/system/runlevel3.target-Multi-user.target//3 level, multi-user mode
lrwxrwxrwx. 1 root root 23:59/usr/lib/systemd/system/runlevel4.target-Multi-user.target//4 level, multi-user mode
lrwxrwxrwx. 1 root root 23:59/usr/lib/systemd/system/runlevel5.target-Graphical.target//5 level, graphics mode
lrwxrwxrwx. 1 root root 23:59/usr/lib/systemd/system/runlevel6.target-Reboot.target
6 levels, restarting
Before entering rescue mode, edit the virtual machine settings, be sure to check the connection at startup, and then select the path of the ISO image file on the CD

Right-click-----Power-----Enter the BIOS------boot

After entering boot, use CD-ROM drive with +-plus minus to the first item, then press F10 to save and exit

In the CD-ROM boot interface, select the third item (first: Install the operating system, second: test the optical drive), enter

Go in, enter. Select the second item, enter

Return to the car and wait.

Enter after 1

Hit the ENTER key, and then typed the flag command: Chroot/mnt/sysimage

Enter passwd root to change the root password, then click Power----Restart the client after the modification is OK

Iii. Cloning virtual machines
Cloning a virtual machine needs to be done in a shutdown state, Right-click on the virtual machine name-----Manage----Clones----Next-----The current state in the virtual machine-------create a linked clone (save space)-------Modify the virtual machine name and file location-------next-------Turn off-----To turn on the newly cloned virtual machine----- --Enter the root account password-------Modify IP address: vi/etc/sysconfig/network-scripts/ifcfg-ens33
Modify the ipaddr, do not conflict with the original virtual machine, delete the UUID line, after modification, save exit.

Then restart the Network service: Systemctl restart Network.service-------View the newly modified ip:ifconfig-----See the hostname of the clone machine: hostname-------Modify the Clone machine hostname: Hostnamectl set-hostname linux-02
(Host name View command: hostname view hostname profile: cat/etc/hostname)
Iv. Linux machines log in to each other
Use format: SSH [email protected] such as SSH [email protected]//SSH default port number: 22
If you need to specify a connection port: ssh-p [email protected]
Key authentication is achieved between two Linux:
[[email protected] ~]# Ssh-keygen//Use the Ssh-keygen command to generate a public key, private key pair
Generating public/private RSA key pair.
Enter file in which to save the key (/ROOT/.SSH/ID_RSA)://Direct ENTER
Enter passphrase (empty for no passphrase)://Enter here directly, default password is empty
Enter same passphrase again://Return to confirm empty password
Your identification has been saved In/root/.ssh/id_rsa. Generate the private key Id_rsa under/root/.ssh/.
Your public key has been saved in/root/.ssh/id_rsa.pub. Generate the public key id_rsa.pub under/root/.ssh/.
The key fingerprint is:
Sha256:gc4yzdzhitfmazatni0dyhtw5/tlwzeb4o4dyjb+xay [email protected]
The key ' s Randomart image is:
+---[RSA 2048]----+
|+.== .. |
|. o+b+. |
|.. =x=o. + |
| + oo .... + |
|. O.. E.oso |
| ... B + |
|
. N
| o =. |
| .. O. |
+----[SHA256]-----+
View the public key private key file generated under the/root/.ssh directory
[Email protected] ~]# LS/ROOT/.SSH
Authorized_keys Id_rsa id_rsa.pub known_hosts
View and copy the Clone machine linux-02 machine just generated public key, copy to linux-01 virtual machine up
[Email protected] ~]# cat/root/.ssh/id_rsa.pub
Ssh-rsa aaaab3nzac1yc2eaaaadaqabaaabaqdjm92zxswytjgke/vmks78knw2getkzbjvnbhxcb/ eetlidavnnbkti0vml6ove24pmscsbxwgdrl/ishnoktsvgjrqcppbt77wscpgnwbt7inedo8jl0b38c31b/ uhaoofh73z5ovb94oilntiygblnaoz/3i2fpr13vmmmbgsdadevpo/our2fb79hnlii4y/ 7md9xkd081koonn1pzqcw7kfqkaaucomkwo0dbq87apoujesafcutjmzc8oonma2yopwvnzck0d6j9mk/oe5+m+uhkwqly7ydhfv+f0ta/ Vpscnitjywkyp92t7m5xaa4l2tn40lvra0wlugliz [email protected]
Edit the/root/.ssh/authorized_keys configuration file for the linux-01 virtual machine and add the public key on the linux-02 machine
[Email protected] ~]# Vi/root/.ssh/authorized_keys
The last line of the configuration file is added as follows to save and exit
# #linux-02
Ssh-rsa aaaab3nzac1yc2eaaaadaqabaaabaqdjm92zxswytjgke/vmks78knw2getkzbjvnbhxcb/ eetlidavnnbkti0vml6ove24pmscsbxwgdrl/ishnoktsvgjrqcppbt77wscpgnwbt7inedo8jl0b38c31b/ uhaoofh73z5ovb94oilntiygblnaoz/3i2fpr13vmmmbgsdadevpo/our2fb79hnlii4y/ 7md9xkd081koonn1pzqcw7kfqkaaucomkwo0dbq87apoujesafcutjmzc8oonma2yopwvnzck0d6j9mk/oe5+m+uhkwqly7ydhfv+f0ta/ Vpscnitjywkyp92t7m5xaa4l2tn40lvra0wlugliz [email protected]
To view the SELinux status:
[[email protected] ~]# Getenforce//view selinux status command
Enforcing//Show SELinux Open
[[email protected] ~]# Setenforce 0//temporarily off SELinux
[[email protected] ~]# Getenforce//view selinux status again
Permissive//Show SELinux is off
Then use the ssh-p [email protected] command on linux-02 to connect linux-01.
[Email protected] ~]# ssh-p [email protected]
Last Login:sun Apr 1 21:42:55 2018 from 192.168.238.1
[[Email protected] ~]#//display has successfully entered the LINUX-01 machine
The interconnection between the two Linux machines does not use a password, which enables a key connection.

Single-user mode rescue mode clone virtual machine Linux machines log in to each other

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.