HOWTO Break into LXC
Jump to navigation
Jump to search
Oops, you locked yourself out of your LXC box! Now what?
Step 1: Have root on WOPR
You need root or sudo on the host, ie WOPR.
Step 2: Know your LXC ID
All LXC boxes have a numeric ID starting at 100.
Go find yours.
Step 3: lxc-attach
LXCs aren't VMs, they're containers. lxc-attach will let you run a command:
$ sudo lxc-attach -n 142 -- ls bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc root run sbin srv sys tmp usr var
Step 4: pwck
pwck syntax checks /etc/passwd and /etc/shadow.
If you edited them and broke them, this will save you.
# lxc-attach -n 142 -- pwck user 'lp': directory '/var/spool/lpd' does not exist user 'news': directory '/var/spool/news' does not exist user 'uucp': directory '/var/spool/uucp' does not exist user 'www-data': directory '/var/www' does not exist user 'list': directory '/var/list' does not exist user 'irc': directory '/run/ircd' does not exist pwck: no changes
Step 5: passwd
passwd will reset your password.
# lxc-attach -n 103 -- passwd New password: Retype new password: passwd: password updated successfully