lxc

How to reset the password for an lxc container

If you find yourself stuck trying to login to an lxc container because you've forgotten the password, here's a simple fix.

With the container stopped, on the host machine (assuming it's ubuntu - other linux flavours may vary slightly), navigate as root to:

/var/lib/lxc/$container_name/rootfs/etc

Then edit the shadow file (perhaps make a backup first), and remove the hash which corresponds to the user's password, leaving the separating colons in place e.g.:

ubuntu::16372:0:99999:7:::

Syndicate content