[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Allowing login via (serial) console by default



On Wed, Dec 19, 2018 at 02:21:33PM +0100, Bastian Blank wrote:
> On Wed, Dec 19, 2018 at 01:58:26PM +0100, Vincent Caron wrote:
> >   I've been using permanent login-less consoles in my LXC containers,
> > because it's very convenient. They actually launch 'getty -l bash ttyXX'
> > which bypasses the password issue. Thus from my point of view having a
> > login-less access is orthogonal to the root password question - and actually
> > I prefer root having no password (and thus no possible interactive login).
> 
> Hmm, thats a different solution.  Just overriding the getty launched by
> serial-getty@.service with the following should force it to auto-login
> as root:
> | ExecStart=-/sbin/agetty --autologin root -o '-p -- -f \\u' --keep-baud 115200,38400,9600 %I $TERM
>

Yep, I do something like this in my automated test VM image
creation script[1] (which starts with a Debian image and then
customizes it):

cp -f /lib/systemd/system/serial-getty@.service \
        /etc/systemd/system/serial-getty@.service
sed -i -e '/ExecStart/s/agetty/agetty -a root/' \
    -e '/ExecStart/s/-p/-p -f/' \
        /etc/systemd/system/serial-getty@.service

BTW, you only need the first sed replacement for stretch; the second
substitution is only need for buster/sid based VM's.  And I think you
need "-p -f -- \\u" since '--' stops the option parsing, and is mainly
to protect against \\u containing a hypthen.

Also BTW, the agetty man page for buster claims that the -a option
automatically adds -f to be passed to the login options:

  -a, --autologin username
         Automatically log in the specified user without asking for  a  username
         or  password.  Using this option causes an -f username option and argu‐
         ment to be added to the /bin/login command line.  See  --login-options,
         which can be used to modify this option's behavior.

This used to be true for stretch, but it's no longer true for buster,
so the man page is out of date.

						- Ted

[1] https://github.com/tytso/xfstests-bld/blob/master/kvm-xfstests/test-appliance/gce-xfstests-bld.sh


Reply to: