访问LXC根用户


0

我对容器不熟悉,正在尝试找出它们。

我无法弄清楚如何以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

硬件...


后来...

以100%的比例观看top节目systemd-journal。当我关闭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实例在LAN上提取IP。

Answers:


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.