Articles in this section

How to change a root password of a root user for a KVM VM via CLI in SolusVM?

Applicable to:

  • SolusVM

Question

How to change a root password of a root user for a KVM VM via CLI in SolusVM?

Answer

It should be done using the Linux native KVM functionality:

  1. Stop a VPS:
    # virsh destroy kvmid
  2. Find the location of its storage:
    # virsh domblklist kvmid
  3. Mount the storage:
    # guestmount  -a PATH -i --rw /mnt_tmp/
  4. Create hash of a new password:
    # openssl passwd -6 -salt AbCdEfGh mypassword
  5. Change permissions of shadow file in a mounted directory:
    # chmod 755 /mnt_tmp/etc/shadow
  6. Open shadow file with a text editor and replace a value of an existing password ( between first and second colons; <password> in my example below):
    root:<password>:0:99999:7:::
  7. Save changes and remove permissions from shadow file:
    # chmod 000 /mnt_tmp/etc/shadow
  8. Unmount the storage:
    # umount /mnt_tmp/
  9. Boot the VPS and confirm that the password has changed:
    # virsh start kvmid

Note: Replace kvmid respectively.

Note: Mounting directory /mnt_tmp/ is given as an example. Another mounting point could be used. Make sure it exists prior mounting.

Note: PATH is the path to a storage from the step 2. mypassword- is your new password

Note: A value after -salt (AbCdEfGh in this example) will define how secure the encryption will be. Make sure you define different values each time you manually changing a password.

For more information use the official RedHat documentation

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.