How to login automatically without typing the root username or password in Buildroot BusyBox init?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
2












If I do:



git clone git://git.buildroot.net/buildroot
cd buildroot
git checkout 2016.05
make qemu_x86_defconfig
make BR2_JLEVEL=2
qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append root=/dev/vda -net nic,model=virtio -net user


I have to type root into QEMU before I can use the shell.



How to configure buildroot to skip that and login directly?



Tested on Ubuntu 16.04.










share|improve this question



























    up vote
    2
    down vote

    favorite
    2












    If I do:



    git clone git://git.buildroot.net/buildroot
    cd buildroot
    git checkout 2016.05
    make qemu_x86_defconfig
    make BR2_JLEVEL=2
    qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append root=/dev/vda -net nic,model=virtio -net user


    I have to type root into QEMU before I can use the shell.



    How to configure buildroot to skip that and login directly?



    Tested on Ubuntu 16.04.










    share|improve this question

























      up vote
      2
      down vote

      favorite
      2









      up vote
      2
      down vote

      favorite
      2






      2





      If I do:



      git clone git://git.buildroot.net/buildroot
      cd buildroot
      git checkout 2016.05
      make qemu_x86_defconfig
      make BR2_JLEVEL=2
      qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append root=/dev/vda -net nic,model=virtio -net user


      I have to type root into QEMU before I can use the shell.



      How to configure buildroot to skip that and login directly?



      Tested on Ubuntu 16.04.










      share|improve this question















      If I do:



      git clone git://git.buildroot.net/buildroot
      cd buildroot
      git checkout 2016.05
      make qemu_x86_defconfig
      make BR2_JLEVEL=2
      qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append root=/dev/vda -net nic,model=virtio -net user


      I have to type root into QEMU before I can use the shell.



      How to configure buildroot to skip that and login directly?



      Tested on Ubuntu 16.04.







      busybox buildroot busybox-init






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 20:09

























      asked Jul 31 '16 at 11:44









      Ciro Santilli 新疆改造中心 六四事件 法轮功

      4,43123938




      4,43123938




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          ::respawn:-/bin/sh



          I was studying the examples/inittab in Busybox 1_28_3 and found this, tried it out, and it worked, so it is the best solution I've found so far.



          Don't forget the leading dash -, or job control does not work as mentioned below.



          The following is equivalent since console is the default:



          console::respawn:-/bin/sh


          The leading dash gets magically parsed by BusyBox' init: https://github.com/mirror/busybox/blob/1_28_3/init/init.c#L439



          I wonder if there is any advantage of using getty over this method when you don't want to require a password.



          Here is a sample setup.



          Previous answer: getty -l



          After almost two years, I've found it! :-)



          Using BR2_ROOTFS_OVERLAY, override / create the following files:



          /etc/inittab: start from https://github.com/buildroot/buildroot/blob/2018.02/package/busybox/inittab and edit the console line to be:



          console::respawn:/sbin/getty -n -L -l /loginroot.sh console 0 vt100


          /loginroot.sh:



          #!/bin/sh
          exec /bin/login root


          /bin/login is the default executable if -l is not given. What we did it to create an executable that calls /bin/login with the user root already specified.



          This makes init try to log in as the root user by default, and then since the default password is empty (BR2_TARGET_GENERIC_ROOT_PASSWD), it automatically logs in.



          This technique basically re-implements the -a <user> option present in Ubuntu 14.04's getty, which BusyBox' implementation doesn't have.



          Then, to login as a different user, just run:



          /bin/login


          Here is a sample setup.



          Previous answer: console::respawn:/bin/sh



          I've asked on the mailing list and Thomas Petazzoni replied that the:



          /etc/inittab


          should contain:



          console::respawn:/bin/sh


          instead of:



          console::respawn:/sbin/getty -n -L console 0 vt100 # GENERIC_SERIAL


          With qemu_x86_defconfig, the inittab is being used by Busybox' init system, due to BR2_INIT_BUSYBOX=y.



          This method does have a downside however: just after login, the message shows:



          /bin/sh can't access tty; job control turned off


          and as advertised, things like Ctrl+C will have no effect.






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f299408%2fhow-to-login-automatically-without-typing-the-root-username-or-password-in-build%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote



            accepted










            ::respawn:-/bin/sh



            I was studying the examples/inittab in Busybox 1_28_3 and found this, tried it out, and it worked, so it is the best solution I've found so far.



            Don't forget the leading dash -, or job control does not work as mentioned below.



            The following is equivalent since console is the default:



            console::respawn:-/bin/sh


            The leading dash gets magically parsed by BusyBox' init: https://github.com/mirror/busybox/blob/1_28_3/init/init.c#L439



            I wonder if there is any advantage of using getty over this method when you don't want to require a password.



            Here is a sample setup.



            Previous answer: getty -l



            After almost two years, I've found it! :-)



            Using BR2_ROOTFS_OVERLAY, override / create the following files:



            /etc/inittab: start from https://github.com/buildroot/buildroot/blob/2018.02/package/busybox/inittab and edit the console line to be:



            console::respawn:/sbin/getty -n -L -l /loginroot.sh console 0 vt100


            /loginroot.sh:



            #!/bin/sh
            exec /bin/login root


            /bin/login is the default executable if -l is not given. What we did it to create an executable that calls /bin/login with the user root already specified.



            This makes init try to log in as the root user by default, and then since the default password is empty (BR2_TARGET_GENERIC_ROOT_PASSWD), it automatically logs in.



            This technique basically re-implements the -a <user> option present in Ubuntu 14.04's getty, which BusyBox' implementation doesn't have.



            Then, to login as a different user, just run:



            /bin/login


            Here is a sample setup.



            Previous answer: console::respawn:/bin/sh



            I've asked on the mailing list and Thomas Petazzoni replied that the:



            /etc/inittab


            should contain:



            console::respawn:/bin/sh


            instead of:



            console::respawn:/sbin/getty -n -L console 0 vt100 # GENERIC_SERIAL


            With qemu_x86_defconfig, the inittab is being used by Busybox' init system, due to BR2_INIT_BUSYBOX=y.



            This method does have a downside however: just after login, the message shows:



            /bin/sh can't access tty; job control turned off


            and as advertised, things like Ctrl+C will have no effect.






            share|improve this answer


























              up vote
              2
              down vote



              accepted










              ::respawn:-/bin/sh



              I was studying the examples/inittab in Busybox 1_28_3 and found this, tried it out, and it worked, so it is the best solution I've found so far.



              Don't forget the leading dash -, or job control does not work as mentioned below.



              The following is equivalent since console is the default:



              console::respawn:-/bin/sh


              The leading dash gets magically parsed by BusyBox' init: https://github.com/mirror/busybox/blob/1_28_3/init/init.c#L439



              I wonder if there is any advantage of using getty over this method when you don't want to require a password.



              Here is a sample setup.



              Previous answer: getty -l



              After almost two years, I've found it! :-)



              Using BR2_ROOTFS_OVERLAY, override / create the following files:



              /etc/inittab: start from https://github.com/buildroot/buildroot/blob/2018.02/package/busybox/inittab and edit the console line to be:



              console::respawn:/sbin/getty -n -L -l /loginroot.sh console 0 vt100


              /loginroot.sh:



              #!/bin/sh
              exec /bin/login root


              /bin/login is the default executable if -l is not given. What we did it to create an executable that calls /bin/login with the user root already specified.



              This makes init try to log in as the root user by default, and then since the default password is empty (BR2_TARGET_GENERIC_ROOT_PASSWD), it automatically logs in.



              This technique basically re-implements the -a <user> option present in Ubuntu 14.04's getty, which BusyBox' implementation doesn't have.



              Then, to login as a different user, just run:



              /bin/login


              Here is a sample setup.



              Previous answer: console::respawn:/bin/sh



              I've asked on the mailing list and Thomas Petazzoni replied that the:



              /etc/inittab


              should contain:



              console::respawn:/bin/sh


              instead of:



              console::respawn:/sbin/getty -n -L console 0 vt100 # GENERIC_SERIAL


              With qemu_x86_defconfig, the inittab is being used by Busybox' init system, due to BR2_INIT_BUSYBOX=y.



              This method does have a downside however: just after login, the message shows:



              /bin/sh can't access tty; job control turned off


              and as advertised, things like Ctrl+C will have no effect.






              share|improve this answer
























                up vote
                2
                down vote



                accepted







                up vote
                2
                down vote



                accepted






                ::respawn:-/bin/sh



                I was studying the examples/inittab in Busybox 1_28_3 and found this, tried it out, and it worked, so it is the best solution I've found so far.



                Don't forget the leading dash -, or job control does not work as mentioned below.



                The following is equivalent since console is the default:



                console::respawn:-/bin/sh


                The leading dash gets magically parsed by BusyBox' init: https://github.com/mirror/busybox/blob/1_28_3/init/init.c#L439



                I wonder if there is any advantage of using getty over this method when you don't want to require a password.



                Here is a sample setup.



                Previous answer: getty -l



                After almost two years, I've found it! :-)



                Using BR2_ROOTFS_OVERLAY, override / create the following files:



                /etc/inittab: start from https://github.com/buildroot/buildroot/blob/2018.02/package/busybox/inittab and edit the console line to be:



                console::respawn:/sbin/getty -n -L -l /loginroot.sh console 0 vt100


                /loginroot.sh:



                #!/bin/sh
                exec /bin/login root


                /bin/login is the default executable if -l is not given. What we did it to create an executable that calls /bin/login with the user root already specified.



                This makes init try to log in as the root user by default, and then since the default password is empty (BR2_TARGET_GENERIC_ROOT_PASSWD), it automatically logs in.



                This technique basically re-implements the -a <user> option present in Ubuntu 14.04's getty, which BusyBox' implementation doesn't have.



                Then, to login as a different user, just run:



                /bin/login


                Here is a sample setup.



                Previous answer: console::respawn:/bin/sh



                I've asked on the mailing list and Thomas Petazzoni replied that the:



                /etc/inittab


                should contain:



                console::respawn:/bin/sh


                instead of:



                console::respawn:/sbin/getty -n -L console 0 vt100 # GENERIC_SERIAL


                With qemu_x86_defconfig, the inittab is being used by Busybox' init system, due to BR2_INIT_BUSYBOX=y.



                This method does have a downside however: just after login, the message shows:



                /bin/sh can't access tty; job control turned off


                and as advertised, things like Ctrl+C will have no effect.






                share|improve this answer














                ::respawn:-/bin/sh



                I was studying the examples/inittab in Busybox 1_28_3 and found this, tried it out, and it worked, so it is the best solution I've found so far.



                Don't forget the leading dash -, or job control does not work as mentioned below.



                The following is equivalent since console is the default:



                console::respawn:-/bin/sh


                The leading dash gets magically parsed by BusyBox' init: https://github.com/mirror/busybox/blob/1_28_3/init/init.c#L439



                I wonder if there is any advantage of using getty over this method when you don't want to require a password.



                Here is a sample setup.



                Previous answer: getty -l



                After almost two years, I've found it! :-)



                Using BR2_ROOTFS_OVERLAY, override / create the following files:



                /etc/inittab: start from https://github.com/buildroot/buildroot/blob/2018.02/package/busybox/inittab and edit the console line to be:



                console::respawn:/sbin/getty -n -L -l /loginroot.sh console 0 vt100


                /loginroot.sh:



                #!/bin/sh
                exec /bin/login root


                /bin/login is the default executable if -l is not given. What we did it to create an executable that calls /bin/login with the user root already specified.



                This makes init try to log in as the root user by default, and then since the default password is empty (BR2_TARGET_GENERIC_ROOT_PASSWD), it automatically logs in.



                This technique basically re-implements the -a <user> option present in Ubuntu 14.04's getty, which BusyBox' implementation doesn't have.



                Then, to login as a different user, just run:



                /bin/login


                Here is a sample setup.



                Previous answer: console::respawn:/bin/sh



                I've asked on the mailing list and Thomas Petazzoni replied that the:



                /etc/inittab


                should contain:



                console::respawn:/bin/sh


                instead of:



                console::respawn:/sbin/getty -n -L console 0 vt100 # GENERIC_SERIAL


                With qemu_x86_defconfig, the inittab is being used by Busybox' init system, due to BR2_INIT_BUSYBOX=y.



                This method does have a downside however: just after login, the message shows:



                /bin/sh can't access tty; job control turned off


                and as advertised, things like Ctrl+C will have no effect.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 9 hours ago

























                answered Aug 3 '16 at 22:25









                Ciro Santilli 新疆改造中心 六四事件 法轮功

                4,43123938




                4,43123938



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f299408%2fhow-to-login-automatically-without-typing-the-root-username-or-password-in-build%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay