注意:6.7U1 及更高版本提供了一种更简单的方法来重置密码,请参见 How to reset the lost or forgotten root password in vCenter Server Appliance 6.7 U1 and later
要重置 vCenter Server Appliance 的 root 密码,请执行以下操作:
- 生成 vCenter Server Appliance 的快照或备份,然后再继续操作。
注意:不要跳过此步骤
注意:如果 vCenter Appliance 位于其管理的 ESXi 主机上,请直接连接到所在的 ESXi 主机以执行以下步骤。
- 重新引导 vCenter Server Appliance。
- 在看到 Photon OS 启动屏幕(如下图所示)后,按 e 键进入 GNU GRUB 编辑菜单。
- 找到以单词 Linux 开头的行。
- 将以下条目附加到该行的末尾:
rw init=/bin/bash
该行应类似以下屏幕截图: - 按 F10 继续引导。
- 运行命令
mount -o remount,rw /
- 在命令提示符下,输入命令 passwd 并提供新的 root 密码(输入两次以进行确认):
passwd
- 运行以下命令,卸载文件系统(没错,卸载命令就是 umount - 这不是拼写错误):
umount /
- 运行以下命令,重新引导 vCenter Server Appliance:
reboot -f
- 确认您可以使用新的 root 密码访问 vCenter Server Appliance。
- 移除步骤 1 中创建的快照(如果适用)。
- 可以将 Root 密码设置为永不过期,以防止出现此问题。可以运行以下命令:# chage -I -1 -m 0 -M 99999 -E -1 root,或在 VAMI (https://<vcenter_fqdn>:5480) 上进行设置。
注意:如果仍然有问题,请参见 Unable to log in to the vCenter Server Appliance shell using root account even after password reset