non-interactive password change of nspawn container

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











up vote
0
down vote

favorite












I want to change passwd of root of nspawn container, as I am creating container via ansible just after I created rootfs, as at very first it doesn't have any root password.



is it a good idea to change passwd by using replace module to replace root line in /etc/shadow file ?



is there any other way too to update the password non-interactively ?



I have tried :



echo user:pass | /usr/sbin/chpasswd


but echo is not working, a I am getting execv() failed: No such file or directory







share|improve this question

























    up vote
    0
    down vote

    favorite












    I want to change passwd of root of nspawn container, as I am creating container via ansible just after I created rootfs, as at very first it doesn't have any root password.



    is it a good idea to change passwd by using replace module to replace root line in /etc/shadow file ?



    is there any other way too to update the password non-interactively ?



    I have tried :



    echo user:pass | /usr/sbin/chpasswd


    but echo is not working, a I am getting execv() failed: No such file or directory







    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I want to change passwd of root of nspawn container, as I am creating container via ansible just after I created rootfs, as at very first it doesn't have any root password.



      is it a good idea to change passwd by using replace module to replace root line in /etc/shadow file ?



      is there any other way too to update the password non-interactively ?



      I have tried :



      echo user:pass | /usr/sbin/chpasswd


      but echo is not working, a I am getting execv() failed: No such file or directory







      share|improve this question













      I want to change passwd of root of nspawn container, as I am creating container via ansible just after I created rootfs, as at very first it doesn't have any root password.



      is it a good idea to change passwd by using replace module to replace root line in /etc/shadow file ?



      is there any other way too to update the password non-interactively ?



      I have tried :



      echo user:pass | /usr/sbin/chpasswd


      but echo is not working, a I am getting execv() failed: No such file or directory









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 12 at 9:39
























      asked Jul 12 at 9:21









      mkmayank

      36310




      36310




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          passwd works for this case. It has an option --stdin. Do not use echo my-secret-password | passwd --stdin, because echo my-secret-password may become visible if someone runs ps, or maybe even in a log file if you are unlucky.



          #!/bin/sh

          PASSWORD=...

          passwd root --stdin <<EOF
          $PASSWORD
          EOF





          share|improve this answer





















          • Thanks for the answer, but this is working fine in host, even the echo one which I mentioned above is running fine too in host, but failing in nspawn container
            – mkmayank
            Jul 12 at 9:52










          • my shadow file was messed up somehow, pwconv helped and its working now
            – mkmayank
            Jul 12 at 10:03










          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%2f454860%2fnon-interactive-password-change-of-nspawn-container%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
          1
          down vote



          accepted










          passwd works for this case. It has an option --stdin. Do not use echo my-secret-password | passwd --stdin, because echo my-secret-password may become visible if someone runs ps, or maybe even in a log file if you are unlucky.



          #!/bin/sh

          PASSWORD=...

          passwd root --stdin <<EOF
          $PASSWORD
          EOF





          share|improve this answer





















          • Thanks for the answer, but this is working fine in host, even the echo one which I mentioned above is running fine too in host, but failing in nspawn container
            – mkmayank
            Jul 12 at 9:52










          • my shadow file was messed up somehow, pwconv helped and its working now
            – mkmayank
            Jul 12 at 10:03














          up vote
          1
          down vote



          accepted










          passwd works for this case. It has an option --stdin. Do not use echo my-secret-password | passwd --stdin, because echo my-secret-password may become visible if someone runs ps, or maybe even in a log file if you are unlucky.



          #!/bin/sh

          PASSWORD=...

          passwd root --stdin <<EOF
          $PASSWORD
          EOF





          share|improve this answer





















          • Thanks for the answer, but this is working fine in host, even the echo one which I mentioned above is running fine too in host, but failing in nspawn container
            – mkmayank
            Jul 12 at 9:52










          • my shadow file was messed up somehow, pwconv helped and its working now
            – mkmayank
            Jul 12 at 10:03












          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          passwd works for this case. It has an option --stdin. Do not use echo my-secret-password | passwd --stdin, because echo my-secret-password may become visible if someone runs ps, or maybe even in a log file if you are unlucky.



          #!/bin/sh

          PASSWORD=...

          passwd root --stdin <<EOF
          $PASSWORD
          EOF





          share|improve this answer













          passwd works for this case. It has an option --stdin. Do not use echo my-secret-password | passwd --stdin, because echo my-secret-password may become visible if someone runs ps, or maybe even in a log file if you are unlucky.



          #!/bin/sh

          PASSWORD=...

          passwd root --stdin <<EOF
          $PASSWORD
          EOF






          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered Jul 12 at 9:40









          sourcejedi

          18k22375




          18k22375











          • Thanks for the answer, but this is working fine in host, even the echo one which I mentioned above is running fine too in host, but failing in nspawn container
            – mkmayank
            Jul 12 at 9:52










          • my shadow file was messed up somehow, pwconv helped and its working now
            – mkmayank
            Jul 12 at 10:03
















          • Thanks for the answer, but this is working fine in host, even the echo one which I mentioned above is running fine too in host, but failing in nspawn container
            – mkmayank
            Jul 12 at 9:52










          • my shadow file was messed up somehow, pwconv helped and its working now
            – mkmayank
            Jul 12 at 10:03















          Thanks for the answer, but this is working fine in host, even the echo one which I mentioned above is running fine too in host, but failing in nspawn container
          – mkmayank
          Jul 12 at 9:52




          Thanks for the answer, but this is working fine in host, even the echo one which I mentioned above is running fine too in host, but failing in nspawn container
          – mkmayank
          Jul 12 at 9:52












          my shadow file was messed up somehow, pwconv helped and its working now
          – mkmayank
          Jul 12 at 10:03




          my shadow file was messed up somehow, pwconv helped and its working now
          – mkmayank
          Jul 12 at 10:03












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454860%2fnon-interactive-password-change-of-nspawn-container%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?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?