Reset root password for Linux Container (LXC)

Setting up Linux containers is very easy in ProxMox, but one of the things that you need to do is set a password when you create the image. Makes sense, especially if others have access to your systems. Sometimes though it’s easy to forget what the password was set to before you set things up enough to allow key based SSH logins.

At least that’s what I did. Doh.

It turns out it’s quite simple to reset the root password for the container. Just do the following on the host that is running the container:

lxc-attach -n <lxc id>

Where <lxc id> is its id number.

Then you’ll be root on your container and can do the usual

passwd

to reset the password, or just

passwd -d

To remove the password altogether, depending on your requirements.