VPS Tutorials
Recover VPS Root Access: Provider Reset, Rescue and GRUB (2026)
Distinguish password errors from SSH failures, use the least disruptive supported recovery route and preserve data before considering reinstallation.

Losing a root password does not automatically require reinstalling a VPS. Existing key-based sudo access, a provider reset, rescue environment or an accessible boot console may restore access while retaining the installed disk. Recovery depends on your provider, image, encryption and disk condition; no procedure guarantees zero data loss.
Start with the least disruptive available route. Confirm that this really is a password problem, follow the provider's documented reset behavior, then consider rescue or GRUB. The final checks cover a correct password that still cannot log in.
| Symptom | Likely direction | Password reset? |
|---|---|---|
Permission denied (publickey) | Key, user or home-directory permissions | Not by itself |
Connection refused / Connection timed out | sshd, port, address, firewall or network | Not by itself |
| Password rejected | Wrong password or image initialization | Potentially |
For the first two, use SSH permission troubleshooting and SSH connectivity.
Cloud images may deliberately lock root and use a normal account such as ubuntu or debian with keys. If that account still has authorized sudo access, use it. sudo passwd root can set a root password when genuinely required, but neither unlocks every remote-login policy nor makes direct root SSH necessary.
Look for controls named:
Root Password/Reset Password/Change Password.Console/VNC/Emergency Console.
SolusVM/Virtualizor panels may expose Root Password on the instance page; the source uses Racknerd as a SolusVM example. Some images inject the new password on the next boot, while others use different mechanisms. Follow the actual provider instructions, including any required restart.
Custom consoles such as BandwagonHost's KiwiVM and Vultr may provide VNC/emergency access or Reset Password. Console availability and reset support vary by product.
- Request the reset through the legitimate account and securely obtain the password.
- Perform the required reboot/boot action, planning service interruption.
- Test the correct account and permitted login method.
- After access, use
passwd rootto replace a temporary password appropriately.
If unavailable or unsuccessful, preserve the error and continue to rescue.
A provider rescue system boots separately and mounts the installed disk for repair/export. Look under Boot, Boot Order or Recovery, select the supported rescue boot and restart.
The sequence is identify root filesystem → mount → chroot → passwd:
# 1. 先看清磁盘布局
lsblk -f
# 常见的根分区名字:
# /dev/vda1 /dev/sda1 /dev/nvme0n1p1
# LVM: /dev/mapper/vg0-root 或 /dev/ubuntu-vg/ubuntu-lv
# 2. 是 LVM 的话先激活卷组
vgchange -a y
# 3. 挂载根分区
mount /dev/vda1 /mnt
# 4. 把运行环境挂进去,否则 passwd 会报错
for d in dev proc sys; do mount --bind /$d /mnt/$d; done
# 5. chroot 进去
chroot /mnt
# 6. 改密码,输两遍新密码
passwd root
# 7. 退出并卸载
exit
umount -R /mnt
reboot
This is illustrative: verify device names, LVM volumes and mountpoints before running it. Encryption requires valid recovery credentials; separate /usr or other filesystem layouts may need additional mounts. Use a compatible rescue architecture. The script already ends with reboot, so restore disk boot before reaching that step, then verify normal startup.
- If
/dev/vda1will not mount, inspectlsblkfor the real device. - If busy, identify existing mounts/users first.
mount -o ro /dev/vda1 /mntis useful for an appropriate read-only inspection, not a universal cure for a busy device. Usemount -o remount,rw /mntonly after confirming the target can safely become writable. - If
chrootfollowed bypasswdreports missing libraries, check the correct root, architecture and any separate /usr. Bind mounts forproc,sysanddevsupport the environment but do not manufacture missing libraries.
See the rescue guide for filesystem/boot repairs beyond password recovery.
If panel reset/rescue is unavailable but you can access an authorized VNC/boot console, a supported GRUB edit may start a root shell using init=/bin/bash. Protected boot menus, encryption and image-specific recovery paths can prevent this route.
- Open the console and reboot in a maintenance window.
- Try
Escor, for some images,Shiftduring boot. - Select the boot entry and press
e. - Locate the
linuxline and appendinit=/bin/bash. - Boot with
Ctrl + X.
The root filesystem may be read-only. After confirming it is the intended healthy filesystem:
mount -o remount,rw /
passwd root
# RHEL / AlmaLinux / Rocky 系:不重建 SELinux 标签,重启后会卡在登录界面或服务起不来
touch /.autorelabel
# 正常重启
exec /sbin/init
# 或强制重启
reboot -f
The example includes alternative restart methods; do not execute them as consecutive steps. Prefer the image's documented normal recovery flow, synchronize writes and avoid forced reboot where unnecessary. The SELinux relabel command applies where that distribution/policy requires it, not universally to every Linux VPS.
- With hidden GRUB and
GRUB_TIMEOUT=0, tryEsc. If a rescue/other trusted entry remains available, adjust/etc/default/grub, setGRUB_TIMEOUTto 5 and runupdate-grub. An inaccessible menu cannot be repaired from a session you cannot obtain; ask the provider. - If
passwdreturnsAuthentication token manipulation error, verify writability before retryingmount -o remount,rw /. Then inspect permissions, filesystem health and immutable attributes on/etc/shadowwithchattr -i /etc/shadow; preserve original attributes before any repair.
- A documented
Windows Password/Reset Administrator Passwordworkflow may require powering off and attaching a recovery ISO or editing offline account data. Follow that provider's exact steps; retain backups and any encryption recovery keys. - Without that facility, ask about supported recovery or disk attachment/export first. Reinstall only after choosing it deliberately and preserving required data; it is not a harmless password reset.
Inspect SSH configuration:
grep -Ei "PasswordAuthentication|PermitRootLogin" /etc/ssh/sshd_config
grep -rEi "PasswordAuthentication|PermitRootLogin" /etc/ssh/sshd_config.d/
PasswordAuthentication nodisables password authentication;PermitRootLogin prohibit-passwordprevents root password login. A new password cannot override those policies. Prefer key-based access. If an intentional configuration change is required, validate effective settings and a second connection beforesystemctl restart ssh.ssh ubuntu@ipselects another account. A root reset applies tossh root@ip; alternatively log in to the authorized normal user and usesu -.- Check
Portinsshd_configor test the real port withssh -p 2222 root@ip. - Check firewall/Fail2Ban blocks; use false-positive recovery.
- Inspect cloud-init/provider synchronization if boot rewrites the password. Correct its documented source rather than repeatedly changing conflicting values.
- A panel's running state does not prove successful OS boot. Read console logs for filesystem checks or startup failures.
Use legitimate account/support recovery for account locks, billing suspension or unavailable consoles. Reinstallation also requires control-plane access and destroys the existing installation unless data has been preserved.
If rescue access is available, export required data before reinstalling:
# 救援系统里:挂载并打包
mount /dev/vda1 /mnt
tar czf /root/site-backup.tar.gz -C /mnt var/www etc/nginx
# 自己电脑上:拉回来
scp root@救援系统IP:/root/site-backup.tar.gz ./
Replace the disk and rescue-address placeholders. This example archives only website files and Nginx configuration; it is not a full system/database backup. Include required databases, application configuration and secrets securely, using a consistent backup method. Avoid unnecessary pseudo-filesystems such as /usr and /var/lib/docker, and verify archives off-host.
In one private support request include instance IP/order ID, desired recovery action, attempted methods and exact errors. Do not include passwords or keys. See the support-request guide and reinstallation guide.
- Use SSH keys; disable passwords only after testing keys and a fallback.
- Store passwords and protected key backups in a trusted password manager.
- Test the provider console and learn its boot controls before an incident.
- Keep verified backups/snapshots; disk failure also requires recovery planning.
When selecting a VPS, assess console, rescue and password-reset capabilities alongside compute resources.
Try existing sudo/key access, provider reset, rescue and console recovery according to availability. A forgotten password does not itself erase data, but recovery success depends on the system and provider. If a reset succeeds but SSH fails, check authentication policy, account, port, blocks and boot state rather than resetting again.