Доступ к корневому пользователю LXC

467
user371793

Я новичок в контейнерах и пытаюсь понять их.

Я не могу понять, как войти в систему как пользователь root на контейнере. Я не могу заставить его принять временный пароль или изменить пароль.

(Да, я уверен, что правильно ввел пароль, хотя в следующем выводе он отображается только один раз. Я набрал себе временный пароль, ввел другой пароль, скопировал и вставил временный пароль. И сделал все вышеизложенное неоднократно. Я удаляю другие попытки для краткости.)

Может ли кто-нибудь помочь мне вернуться?

Я с подозрением отношусь к проблеме с разрешениями, но не смог выяснить, какими должны быть разрешения ...

sed: can't read /var/lib/lxc/centostest/rootfs/etc/init/tty.conf: No such file or directory Storing root password in '/var/lib/lxc/centostest/tmp_root_pass' chpasswd: cannot open /etc/passwd Expiring password for user root. passwd: Libuser error at line: 413 - Error replacing `/etc/passwd': Permission denied. passwd: Error 

Вот весь вывод терминала от создания контейнера через попытки корневого доступа и попытки сброса пароля ....

[root@centos01 ~]# lxc-create -n centostest -t centos Host CPE ID from /etc/os-release: cpe:/o:centos:centos:7 Checking cache download in /var/cache/lxc/centos/x86_64/7/rootfs ...  Cache found. Updating... Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: linorg.usp.br * extras: linorg.usp.br * updates: linorg.usp.br No packages marked for update Loaded plugins: fastestmirror Cleaning repos: base extras updates 0 package files removed Update finished Copy /var/cache/lxc/centos/x86_64/7/rootfs to /var/lib/lxc/centostest/rootfs ...  Copying rootfs to /var/lib/lxc/centostest/rootfs ... sed: can't read /var/lib/lxc/centostest/rootfs/etc/init/tty.conf: No such file or directory Storing root password in '/var/lib/lxc/centostest/tmp_root_pass' chpasswd: cannot open /etc/passwd Expiring password for user root. passwd: Libuser error at line: 413 - Error replacing `/etc/passwd': Permission denied. passwd: Error sed: can't read /var/lib/lxc/centostest/rootfs/etc/rc.sysinit: No such file or directory sed: can't read /var/lib/lxc/centostest/rootfs/etc/rc.d/rc.sysinit: No such file or directory  Container rootfs and config have been created. Edit the config file to check/enable networking setup.  The temporary root password is stored in:  '/var/lib/lxc/centostest/tmp_root_pass'   The root password is set up as expired and will require it to be changed at first login, which you should do as soon as possible. If you lose the root password or wish to change it without starting the container, you can change it from the host by running the following command (which will also reset the expired flag):  chroot /var/lib/lxc/centostest/rootfs passwd  [root@centos01 ~]# vi /var/lib/lxc/centostest/tmp_root_pass [root@centos01 ~]# lxc-start -n centostest -d [root@centos01 ~]# lxc-console -n centostest -t 0  Connected to tty 0 Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself  CentOS Linux 7 (Core) Kernel 3.10.0-693.17.1.el7.x86_64 on an x86_64  centostest login: root Password:  Login incorrect  centostest login: [root@centos01 ~]#  [root@centos01 ~]# lxc-stop -n centostest [root@centos01 ~]# chroot /var/lib/lxc/centostest/rootfs passwd Changing password for user root. New password:  Retype new password:  passwd: Authentication token manipulation error [root@centos01 ~]# lxc-start -n centostest -d [root@centos01 ~]# lxc-console -n centostest -t 0  Connected to tty 0 Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself  CentOS Linux 7 (Core) Kernel 3.10.0-693.17.1.el7.x86_64 on an x86_64  centostest login: root Password:  Login incorrect 

Оборудование ...


Потом...

Оглядываюсь с topшоу systemd-journalна 100%. Когда я выключаю экземпляр LXC, он уходит.

Итак, я пошел в journalctl. Это то, что я вижу, когда я, journalctl -fкогда я запускаю экземпляр ...

Feb 28 13:11:15 centos01.lan kernel: virbr3: port 2(vethGC75VP) entered blocking state Feb 28 13:11:15 centos01.lan kernel: virbr3: port 2(vethGC75VP) entered disabled state Feb 28 13:11:15 centos01.lan kernel: device vethGC75VP entered promiscuous mode Feb 28 13:11:15 centos01.lan kernel: IPv6: ADDRCONF(NETDEV_UP): vethGC75VP: link is not ready Feb 28 13:11:15 centos01.lan NetworkManager[3741]: <info> [1519841475.4600] manager: (veth5WRBVL): new Veth device (/org/freedesktop/NetworkManager/Devices/31) Feb 28 13:11:15 centos01.lan NetworkManager[3741]: <info> [1519841475.4645] manager: (vethGC75VP): new Veth device (/org/freedesktop/NetworkManager/Devices/32) Feb 28 13:11:15 centos01.lan kernel: IPv6: ADDRCONF(NETDEV_CHANGE): vethGC75VP: link becomes ready Feb 28 13:11:15 centos01.lan kernel: virbr3: port 2(vethGC75VP) entered blocking state Feb 28 13:11:15 centos01.lan kernel: virbr3: port 2(vethGC75VP) entered forwarding state Feb 28 13:11:15 centos01.lan NetworkManager[3741]: <info> [1519841475.4936] device (vethGC75VP): link connected 

Что не имеет смысла для меня, так это то, что я вижу, как экземпляр LXC тянет IP-адрес в локальной сети.

0

1 ответ на вопрос

0
Marco Mazzucco

У меня была похожая проблема. Временно отключите selinux (setenforce 0), а затем выполните lxc-destroy, а затем create. Процесс создания не подходит для selinux.