Lately I had on of these problems that could run into real trouble… … unless you find a very easy solution for it.
I wanted to su to root and realised that I’ve forgotten the root password. OK, not a big deal, I usually allow sudo for my user. BUT, I couldn’t remember my password either… sigh I always logged in via SSH with an authorised key, hence not using my password for quite a while.
The solution is as easy as simple. Shutdown your domain
xm shutdown domain -w, mount your image as loop device
mount -o loop /path/to/your/domain.img /mnt and chroot into it.
The only thing left to do is to change your password via
passwd, unmount your image and start your domain again
xm create /etc/xen/domain.cfg