Linux forgot root password How to change password and multiple Linux mutual use key connection

Source: Internet
Author: User

1.13 Single-user mode   

If you forget your Linux password, you can change the password in single-user mode. The premise is that we need to know the grub password (or grub has no password) and if you don't know the grub password then use rescue mode to change the password.

1.13.1 reboot your virtual machine (reboot, init 6, Shutdown-r Now these commands are commands to restart the system. Init 0, Poweroff These are the system shutdown commands. )

Right click = "SELECT power =" Restart Client

When you see this interface, press the up and down keys of the keyboard to select the first item. You can see the options at 2 and then press the "E" key on the keyboard.

Enter Grub, press the DOWN ARROW key to find the linux16 option and then position the cursor to RO (read-only) and change the RO to RW (read-write), followed by init=/sysroot/bin/sh (meaning that you load the command line so that you can change the password), and then press the keyboard CTRL +x

At this point you are in the directory you are in your original system root directory. We've configured the/root/.ssh/authroized_keys file before.

We can use Cta/sysroot/root/.ssh/authroized_keys to view

1.13.2 How to switch to the directory under the previous root user that we can use chroot/sysroot/ run again Cta/root/.ssh/authroized_keys we can see we've entered the

1.13.3. change user password passwd root

A small box appears stating that the virtual machine does not support Chinese, we need to define it as English run lang=en: the definition language is English (CTRL + C can terminate the current command)

1.13.4 now we can log in with the new password, before we run a command touch/.autorelabel and then we can restart the client.

Enter the system input user and new password.

This method is only suitable for operation on Linux native computer. 1.14 Rescue Mode There are 7 running levels, from 0 to 6, and we just said that the single user is 1.



1.14.1 using rescue mode to change the password


(Turn off the machine, give the virtual machine edit = "Select Cd/dvd=" to select Start-up connection) and then choose your image file path.

Start the CD-ROM drive, which is the first startup object

Select Boot

Use the keyboard plus minus sign to put the CD-ROM to the first item,

Press the F10 of the keyboard to save, enter

Enter

Enter

in the carriage return , it means entering the root user directory below to enter this command

1.14.2 then enter the passwd root command to change the password

1.14.3 give your optical drive power off, set the method

1.14.4 then the computer right-click = "Power =" Restart the client, use your new password to log in to the root user the benefit of rescue mode is that when you change the computer configuration file is wrong to cause your computer will not be able to drive, you can use this method to change the wrong file in the right.



1.15 Cloning a virtual machine


1.15.1 Put your virtual machine

Linked clones use less space and do not need to be fully cloned

You can make a name and choose where to store it.

1.15.2 Modify the IP address of your cloned machine, or it will be in conflict with your other machine when it starts up . Enter the NIC configuration file

Edit OK Press ESC to exit, and then press (: WQ) Enter

Restart the network server

1.15.3 Modify the name of the host This is the configuration file that changes the host name directly, you can restart the host to see the changed host name.

1.15.4 cloning machine using the Xshell key can also log in, because the key is the same, you need to change the password on the line.



1.16linux machine log in with each other


1.16.1 using Xshell to open our two Linux machines

We make the "w" Command View momoco-02 has several terminals

We then use momoco-01 to connect the momoco-02

Take a look at 1 and 2, enter the momoco-02 password after you enter 1 to return the car, you can log in momoco-02

Go back to momoco-02 and see how many terminals

Here is the momoco-01 login momoco-02 information, ctrl+d "can exit the current user"

1.16.2 standard notation for remote connection commands

[email protected] ~]# ssh-p [email protected] -P Number "Remote connection specified port" defaults to port 22 If you do not enter this entry [email protected] "username username IP Address" If you do not enter a user name, the default is the root user

1.16.32 machines use keys to log in with each other Our Linux also has a key function

enter [[email protected] ~]# Ssh-keygen 1-place return. 2 Set password do not want the password to enter directly. 3-place return. 4 is the path to the private key. 5 is the path to the public key

We're pasting the public key into Momoco-01 's/root/.ssh/authorized_keys. the same method can be set momoco-02, so that the root password can not be logged into each other

1.16.4 Close SELinux

[[email protected] ~]# Getenforce "See if SELinux is off" Show this is not off

use [[email protected] ~]# Setenforce 0 to temporarily close

Linux forgot root password How to change password and multiple Linux mutual use key connection

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.