[lxc-devel] [PATCH 1/3] lxc-debian: define a password for root

Laurent Vivier laurent at vivier.eu
Sat Jun 18 15:23:45 UTC 2016



Le 18/06/2016 à 15:13, Laurent Vivier a écrit :
> 
> 
> Le 17/06/2016 à 16:52, serge at hallyn.com (Serge E. Hallyn) a écrit :
>> Quoting Laurent Vivier (laurent at vivier.eu):
>>> Signed-off-by: Laurent Vivier <laurent at vivier.eu>
>>
>> Sorry but isn't this a regression?  How about making this subject to a
>> --default-password argument or something?
> 
> Oh, yes... I've found:
> 
>    515fb8d do not set the root password in the debian template
> 
>    https://github.com/lxc/lxc/issues/302
> 
>> I think Michael said he might be around right now, and at one point
>> he was trying to standardize this across templates, so maybe he wants
>> to comment (cc:d)
> 
> With old version of debian, you can have a root with no password: so at
> login you just type "root" , no password is asked and you are logged in.
> 
> With the last versions of debian, this doesn't work: you can't login
> without having defined a password.
> 
> I think it is not worst than having a sudoer "ubuntu" with password
> "ubuntu"...
> 
> I'm open to any other proposition allowing to login into the container.

Perhaps configuring autologin on tty2-tty4 could be a solution?

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index 2877675..04e48b5 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -218,6 +218,7 @@ configure_debian_systemd()
     if [ -f ${rootfs}/lib/systemd/system/getty\@.service ]; then
        sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \
            -e 's/After=dev-%i.device/After=/' \
+           -e 's?^ExecStart=-/sbin/agetty ?ExecStart=-/sbin/agetty -a
root ?' \
            < ${rootfs}/lib/systemd/system/getty\@.service \
            > ${rootfs}/etc/systemd/system/getty\@.service
     fi

Laurent

> Thanks,
> Laurent
> 
>>> ---
>>>  templates/lxc-debian.in | 4 ++++
>>>  1 file changed, 4 insertions(+)
>>>
>>> diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
>>> index 56953b6..5dc4e0b 100644
>>> --- a/templates/lxc-debian.in
>>> +++ b/templates/lxc-debian.in
>>> @@ -163,6 +163,10 @@ EOF
>>>          echo "Timezone in container is not configured. Adjust it manually."
>>>      fi
>>>  
>>> +    echo "root:root" | chroot $rootfs chpasswd
>>> +    chroot $rootfs passwd -e root
>>> +    echo "Root password is 'root', please change !"
>>> +
>>>      return 0
>>>  }
>>>  
>>> -- 
>>> 2.5.5
>>>
>>> _______________________________________________
>>> lxc-devel mailing list
>>> lxc-devel at lists.linuxcontainers.org
>>> http://lists.linuxcontainers.org/listinfo/lxc-devel
>>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
> 


More information about the lxc-devel mailing list