• About Altaro
  • About Altaro VM Backup
  • 101 Free VMware Tools
  • facebook
  • twitter
  • google+
  • linkedin
  • rss
  • About Altaro
  • About Altaro VM Backup
  • 101 Free VMware Tools
vSphere
Altaro.com » Altaro's VMware Hub and blog » vSphere » How to reset the root password for VCSA 6.x
Jason Fenech
by Jason Fenech in vSphere
Tags: vCSA, VCSA 6.5, vSphere

How to reset the root password for VCSA 6.x

24 Apr 2017 by Jason Fenech
4 vSphere
 

 

 

 

In general, I tend to store all my passwords in something like KeePass or some other password management tool. I also have a habit of jotting down credential details in the annotation or notes field for any VM I create for testing purposes. This serves as a quick self-reminder whenever I need to log on a VM and also help users access a VM when required.

To cut a long story short, I found myself trying to log in as root on a test VCSA I had recently set up and, for the life of me, I could not recall the password. As luck would have it, I neither saved the password to KeePass nor did I write it down in VM’s annotation field. So much for good habits!

Figure 1 - The Annotations / Notes fields as displayed in the vSphere traditional and Web clients
Figure 1 – The Annotations / Notes fields as displayed in the vSphere traditional and Web clients

 

As I wasn’t particularly keen on reinstalling the appliance from scratch, I googled around to see if resetting a root password on vCSA can be done. Surely enough it can, hence today’s post! So, if you ever found yourself locked out of VCSA because you forgot the root password, read on!

Disclaimer: I tested the procedure on VCSA 6.0 U2 and VCSA 6.5. In theory, it should work on earlier releases but I do not have the time to test this out on every version released to date. Do so at your own risk and always back up the appliance before effecting any changes.

 

VCSA 6.5


First, shut down the VCSA and take a snapshot.

1. Start the appliance up and press the space bar to freeze the GRUB menu. Note that you need to be somewhat quick here.

2. Press e to enable edit mode.

3. Append rw init=/bin/bash to the list of options as shown in Fig. 2.

Figure 2 - Setting the boot options in GRUB
Figure 2 – Setting the boot options in GRUB

 

4. Press F10 to reboot. The appliance will now boot up in bash or root shell.

5. Type passwd to change the root password. Type it twice and press Enter to confirm.

6. Optionally, you can unmount the file system using umount /

Figure 3 - Changing the root password and unmounting the file system
Figure 3 – Changing the root password and unmounting the file system

 

7. Reboot the appliance using the power options from the VMRC or vSphere client menu.

Figure 4 - Rebooting the appliance from VMRC or vSphere client
Figure 4 – Rebooting the appliance from VMRC

 

You should now be able to log in with root using the new password as shown in this next video.

https://www.altaro.com/vmware/wp-content/uploads/2017/01/VCSA-6.5-password-reset.mp4

 

 

VCSA 6.0 Update 2


The process is very similar to the one for VCSA 6.5. First, shut down the VCSA and take a snapshot.

1. Press the space bar to freeze the GRUB menu.

2. Press p and type in the password to unlock the advanced features in GRUB (refer to The GRUB Password section further down).

Figure 5 - Accessing advanced features in GRUB
Figure 5 – Accessing advanced features in GRUB

3. Press e to enable Edit mode

4. Select the entry starting with “kernel /vmlinuz- …” and press e once more.

Figure 6 - Editing the boot up options in GRUB
Figure 6 – Editing the boot up options in GRUB

 

5. Append init=/bin/bash to the kernel boot options

Figure 7 - Setting the VCSA to boot up as a root shell
Figure 7 – Setting the VCSA to boot up as a root shell

 

6. Press Enter followed by b. This reboots the appliance in single-user mode.

7. Type in the passwd command. Type in the new password twice and press Enter to confirm.

Figure 8 - Changing the root password from a root shell
Figure 8 – Changing the root password from a root shell

 

8. Reboot the appliance using the power options from the VMRC or vSphere client. Alternatively, you can use the reboot shell command. If this fails, run mkfifo /dev/initct first followed by reboot -f.

Here’s a second video illustrating the password change procedure on 6.0 U2.

https://www.altaro.com/vmware/wp-content/uploads/2017/01/VCSA-6.0-U2-password-reset.mp4

 

 

The GRUB Password


While carrying out research for this post, most of the info I came across stated that the GRUB password on VCSA is set to vmware by default unless the root password was changed via VAMI, in which case both the GRUB and root password are set to be the same. When I installed VCSA 6.0 U2 (version 6.0.0.20000-3634791) I found that this was not the case. The GRUB password was by default set the same as that for root. At no point during the vCSA installation do you get to set the GRUB password and you also cannot skip setting one for root.  So, I don’t know how and when the GRUB password is set to vmware. And yes, I’m positive that I did not change the root password using VAMI or otherwise.

Figure 9 - Setting the root password while installing VCSA 6.0 U2
Figure 9 – Setting the root password while installing VCSA 6.0 U2

 

Why am I ranting? Well, if this is the default behavior in U2 you are faced with two issues if you happen to lose or forget the root password. It logically follows that if you’re locked out from making changes to GRUB, there is no way you can reset the root password. Not all hope is lost, however. You can use a technique similar to the one used to recover Windows passwords. Here’s a good link that outlines this procedure.

Note: On VCSA 6.5 you’ll find that access to GRUB is not password protected much to the horror of the security folk!

 

Changing the root password and expiration settings


There will be times where you will not be able to log in as root despite being sure that you’re typing in the correct password. This will occur whenever the root password expires after the default password lifetime of 365 days. Additionally, it is very common to set the expiration period to 90 days or less to tighten up security. You can disable password expiry altogether but this is definitely not recommended.

The root password and expiry settings are easily managed using VAMI which you will access via this https://<VCSA FQDN or IP>:5480> link. Figures 10-11, show the root account management pages for VCSA 6.0 U2 and 6.5 respectively.

Figure 10 - VCSA 6.0 U2: Root password and expiration settings in VAMI
Figure 10 – VCSA 6.0 U2: Root password and expiration settings in VAMI

 

Figure 10 - VCSA 6.5: Root password and expiration settings in VAMI
Figure 10 – VCSA 6.5: Root password and expiration settings in VAMI

 

Alternatively, use the chage command from the ESXi shell as shown in Figure 11 which consists of a screen grab of the root settings in VAMI next to a screen grab of the VCSA VM’s console while in shell. Here’s a step by step explanation of the commands used.

1. chage -l root : Displays the account details for root which include the account and password expiry dates, the date at which the password was last changed, etc.

2. passwd : This command simply prompts you to change the password of the currently logged on user, which in this case happens to be root.

3. chage -M 30 root : Here I’ve used the chage command to set the password expiration period to 30 days from when the password was last changed.

4. Same as (1). You can see that the “Maximum number of days between password change“value – which is a bit misleading if you ask me – is now set to 30. The change is also reflected in the VAMI settings screens when it is refreshed.

Figure 11 - Changing the expiration period of an account using chage
Figure 11 – Changing the expiration period of an account using chage

 

This concludes today’s post. As always, make sure to take a snapshot or a backup of the appliance when committing these type of changes. This allows you to quickly revert to a working vCSA instance should you hit a dead end.

Have any questions or feedback?

Leave a comment below!

Jason Fenech
Jason Fenech

An IT veteran for over 23 years, I covered various roles throughout my career. Prior to joining Altaro as a blog writer and QA tester, I was employed as an infrastructure engineer at a cloud services provider working exclusively with VMware products. The Altaro VMware blog enables me to share the experience and knowledge gained and, much to my surprise, is what got me the vExpert 2017 award. Besides being a techie and a science buff, I like to travel and play guitars. I also do some photography and love having a go at playing the occasional XBOX game, Halo being my absolute favourite. I am also a proud father of two and parent to a crazy Dachshund called Larry.

All Posts   WEBSITE   EMAIL

4 Comments on “How to reset the root password for VCSA 6.x”

  1. Thomas G. January 30, 2018 at 5:35 pm

    Thank you very much for the article. The section where you outline how to reset the password on a 6.5 VCSA via the shell helped me resolve an issue that was preventing an upgrade to one of our sites.

    Reply
    1. Jason FenechJason Fenech Post authorFebruary 2, 2018 at 8:23 am

      Good to hear. Thank you for your feedback.

      Jason.

      Reply
  2. Mmir June 25, 2018 at 11:02 pm

    Thanks for this .. It did save my day

    Reply
    1. Jason FenechJason Fenech Post authorJuly 19, 2018 at 11:56 am

      Glad you found it useful. Thanks for the feedback.

      Reply

Click here to cancel reply.

Have a question or comment? We'd love to hear it! Cancel reply

Your email address will not be published. Required fields are marked *

XHTML: You can use these tags <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

 

Featured product

Download Altaro VM Backup

Download 30-day trial or Free Edition (free for 2 VMs, forever.)

Site categories

  • vSphere
  • Storage
  • Automation and Management
  • Altaro News
  • Desktop Virtualization
  • HyperConvergence
  • Cloud
  • Uncategorized

Altaro Software

  • About Altaro
  • Altaro VM Backup

Altaro VM Backup

  • Altaro VM Backup
  • Download Free Version
  • Download 30-day Trial

Our writers

  • Jason Fenech Jason Fenech
    142 Posts
  • Andy Syrewicze (Chief Editor) Andy Syrewicze (Chief Editor)
    24 Posts
  • Ryan Birk
    22 Posts
  • Luke Orellana Luke Orellana
    18 Posts

Copyright © 2018 Altaro Software.

  • facebook
  • twitter
  • google+
  • linkedin
  • rss
[contact-form-7 id="4731" title="Act-On subs"]