I'm using Openstack with KVM and libvirt. when I try to reset instance password with nova api, I received error 501 not Implemented! How can I change instance password?
2 Answers
With KVM hypervisor resetting the password of an instance is not supported using nova 'root-password' due to limitations of KVM. The 'nova root-password' is only supported in xenapi with a guest agent running.
However you may inject password in instances at launching time on Libvirt-based hypervisors (KVM, QEMU, LXC).
For hypervisors such as KVM that use the libvirt backend, admin/root password injection is disabled by default. To enable it, set the following option in /etc/nova/nova.conf:
[libvirt]
inject_password=true
When enabled, Compute will modify the password of the root account by editing the /etc/shadow file inside of the virtual machine instance.
Users can only ssh to the instance by using the admin password if:
The virtual machine image is a Linux distribution
The virtual machine has been configured to allow users to ssh as the root user. This is not the case for Ubuntu cloud images, which disallow ssh to the root account by default.

- 361
- 1
- 3
- 9
You can use guestfish as it is explained here. Basically you need to install the tool:
apt-get update
apt-get install libguestfs-tools or guestfish (depends on your distro)
Then you can modify directly the VM image (remember to shut down the VM before doing any modification to avoid corruption issues):
cd /var/lib/nova/instances/<your instance GUID>/
guestfish --rw -a disk -i edit /etc/ssh/sshd_config
So you can include
PasswordAuthentication no
Then you can ssh your VM using the key you generated during creation. Or you can modify the password.
guestfish --rw -a disk -i edit /etc/sudoers
Include at the end of the file for instance
[USERNAME] ALL=(ALL) NOPASSWD: ALL
Finally to change the password:
guestfish --rw -a disk -i command "bash -c 'echo USERNAME:PASSWORD | chpasswd'"

- 3,011
- 5
- 21
- 41