How to set user passwords using passwd without a prompt?Bash script to automaticly change a given user's passwordHow to change password using usermod?How to change passwords in bulk? Ubuntu 16.04Problem running Linux Bash Script and adding password same as usernameSet another password automatically every day for a user sessionHow to setup a list of users using bashWhy am I not asked for password at startup?How to login into Ubuntu after an upgrade to 12.04?chpasswd silently fails to do anything; is there a substitute?How to configure pkexec to not ask for password?Default sudo settings did not require passwordChange expired password via sshUbuntu Keyring on Library Public ComputersCannot change password using passwdOS “Forgets” User PasswordsBash script to automaticly change a given user's password

Hero deduces identity of a killer

Does malloc reserve more space while allocating memory?

How does a computer interpret real numbers?

Recommended PCB layout understanding - ADM2572 datasheet

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

Add big quotation marks inside my colorbox

Does IPv6 have similar concept of network mask?

What is the evidence for the "tyranny of the majority problem" in a direct democracy context?

Why does AES have exactly 10 rounds for a 128-bit key, 12 for 192 bits and 14 for a 256-bit key size?

It grows, but water kills it

Multiplicative persistence

Extract more than nine arguments that occur periodically in a sentence to use in macros in order to typset

How does the math work for Perception checks?

Why is this estimator biased?

Is there a way to get `mathscr' with lower case letters in pdfLaTeX?

Are Captain Marvel's powers affected by Thanos' actions in Infinity War

Why can Carol Danvers change her suit colours in the first place?

How could a planet have erratic days?

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?

What happens if you are holding an Iron Flask with a demon inside and walk into an Antimagic Field?

Mixing PEX brands

Invalid date error by date command

What is going on with 'gets(stdin)' on the site coderbyte?

Has any country ever had 2 former presidents in jail simultaneously?



How to set user passwords using passwd without a prompt?


Bash script to automaticly change a given user's passwordHow to change password using usermod?How to change passwords in bulk? Ubuntu 16.04Problem running Linux Bash Script and adding password same as usernameSet another password automatically every day for a user sessionHow to setup a list of users using bashWhy am I not asked for password at startup?How to login into Ubuntu after an upgrade to 12.04?chpasswd silently fails to do anything; is there a substitute?How to configure pkexec to not ask for password?Default sudo settings did not require passwordChange expired password via sshUbuntu Keyring on Library Public ComputersCannot change password using passwdOS “Forgets” User PasswordsBash script to automaticly change a given user's password













16















I am writing a script to add a large amount of users to a system. Part of this involves setting default passwords for each user. How can I set users' passwords without it prompting me for the password up front?



Unfortunately passwd doesn't seem to take an argument stating the new password to set. I'm using Ubuntu 11.10.










share|improve this question




























    16















    I am writing a script to add a large amount of users to a system. Part of this involves setting default passwords for each user. How can I set users' passwords without it prompting me for the password up front?



    Unfortunately passwd doesn't seem to take an argument stating the new password to set. I'm using Ubuntu 11.10.










    share|improve this question


























      16












      16








      16


      2






      I am writing a script to add a large amount of users to a system. Part of this involves setting default passwords for each user. How can I set users' passwords without it prompting me for the password up front?



      Unfortunately passwd doesn't seem to take an argument stating the new password to set. I'm using Ubuntu 11.10.










      share|improve this question
















      I am writing a script to add a large amount of users to a system. Part of this involves setting default passwords for each user. How can I set users' passwords without it prompting me for the password up front?



      Unfortunately passwd doesn't seem to take an argument stating the new password to set. I'm using Ubuntu 11.10.







      password






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 1 '16 at 4:09









      muru

      1




      1










      asked Nov 18 '11 at 11:06









      Jake PetroulesJake Petroules

      183116




      183116




















          4 Answers
          4






          active

          oldest

          votes


















          18














          Try usermod:



          usermod --password PASSWORD USERNAME


          The only thing is this needs a pre-encrypted password string which you'd have to generate first.






          share|improve this answer


















          • 1





            ...which I can generate using mkpasswd. Excellent, thanks!

            – Jake Petroules
            Nov 18 '11 at 11:27






          • 13





            You can also use openssl to generate the encrypted password. For example: usermod --password $(echo my_new_password | openssl passwd -1 -stdin) USERNAME

            – Eric Smith
            Jan 16 '15 at 19:34











          • Three years too late. I couldn't make the answer @EricSmith, but I did discover a simpler version of the command that did work: usermod --password $(openssl passwd -1 password) username

            – BoCoKeith
            Nov 29 '18 at 15:36



















          9














          You should look at the chpasswd command (if available in your linux flavor):



          echo 'userid:newpasswd' | chpasswd


          Or, you can cat a file listing userid:passwd for each account on a separate line.



          That's it.






          share|improve this answer

























          • this worked for me in Dockerfile

            – Vishrant
            Jan 27 at 18:58


















          1














          Inspired by Eric Smith's idea, combining openssl passwd and usermod -p command worked. Generate hashed value of password along with salt value.



          $ openssl passwd -1 -salt 5RPVAd clear-text-passwd43
          $1$5RPVAd$vgsoSANybLDepv2ETcUH7.


          Then, copy the encrypted string to usermod. Make sure to wrap it with single quote.



          $ usermod -p '$1$5RPVAd$vgsoSANybLDepv2ETcUH7.' root


          Check it out in shadow file.



          $ grep root /etc/shadow
          root:$1$5RPVAd$vgsoSANybLDepv2ETcUH7.:17774:0:99999:7:::





          share|improve this answer
































            0














            You should use password aging, and set the users so that they must change their password on the first login. See this article.






            share|improve this answer























            • These intended to be FTP-only accounts, but good advice. ;)

              – Jake Petroules
              Nov 18 '11 at 22:49










            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            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',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f80444%2fhow-to-set-user-passwords-using-passwd-without-a-prompt%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            18














            Try usermod:



            usermod --password PASSWORD USERNAME


            The only thing is this needs a pre-encrypted password string which you'd have to generate first.






            share|improve this answer


















            • 1





              ...which I can generate using mkpasswd. Excellent, thanks!

              – Jake Petroules
              Nov 18 '11 at 11:27






            • 13





              You can also use openssl to generate the encrypted password. For example: usermod --password $(echo my_new_password | openssl passwd -1 -stdin) USERNAME

              – Eric Smith
              Jan 16 '15 at 19:34











            • Three years too late. I couldn't make the answer @EricSmith, but I did discover a simpler version of the command that did work: usermod --password $(openssl passwd -1 password) username

              – BoCoKeith
              Nov 29 '18 at 15:36
















            18














            Try usermod:



            usermod --password PASSWORD USERNAME


            The only thing is this needs a pre-encrypted password string which you'd have to generate first.






            share|improve this answer


















            • 1





              ...which I can generate using mkpasswd. Excellent, thanks!

              – Jake Petroules
              Nov 18 '11 at 11:27






            • 13





              You can also use openssl to generate the encrypted password. For example: usermod --password $(echo my_new_password | openssl passwd -1 -stdin) USERNAME

              – Eric Smith
              Jan 16 '15 at 19:34











            • Three years too late. I couldn't make the answer @EricSmith, but I did discover a simpler version of the command that did work: usermod --password $(openssl passwd -1 password) username

              – BoCoKeith
              Nov 29 '18 at 15:36














            18












            18








            18







            Try usermod:



            usermod --password PASSWORD USERNAME


            The only thing is this needs a pre-encrypted password string which you'd have to generate first.






            share|improve this answer













            Try usermod:



            usermod --password PASSWORD USERNAME


            The only thing is this needs a pre-encrypted password string which you'd have to generate first.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 18 '11 at 11:18









            CaesiumCaesium

            11.6k33147




            11.6k33147







            • 1





              ...which I can generate using mkpasswd. Excellent, thanks!

              – Jake Petroules
              Nov 18 '11 at 11:27






            • 13





              You can also use openssl to generate the encrypted password. For example: usermod --password $(echo my_new_password | openssl passwd -1 -stdin) USERNAME

              – Eric Smith
              Jan 16 '15 at 19:34











            • Three years too late. I couldn't make the answer @EricSmith, but I did discover a simpler version of the command that did work: usermod --password $(openssl passwd -1 password) username

              – BoCoKeith
              Nov 29 '18 at 15:36













            • 1





              ...which I can generate using mkpasswd. Excellent, thanks!

              – Jake Petroules
              Nov 18 '11 at 11:27






            • 13





              You can also use openssl to generate the encrypted password. For example: usermod --password $(echo my_new_password | openssl passwd -1 -stdin) USERNAME

              – Eric Smith
              Jan 16 '15 at 19:34











            • Three years too late. I couldn't make the answer @EricSmith, but I did discover a simpler version of the command that did work: usermod --password $(openssl passwd -1 password) username

              – BoCoKeith
              Nov 29 '18 at 15:36








            1




            1





            ...which I can generate using mkpasswd. Excellent, thanks!

            – Jake Petroules
            Nov 18 '11 at 11:27





            ...which I can generate using mkpasswd. Excellent, thanks!

            – Jake Petroules
            Nov 18 '11 at 11:27




            13




            13





            You can also use openssl to generate the encrypted password. For example: usermod --password $(echo my_new_password | openssl passwd -1 -stdin) USERNAME

            – Eric Smith
            Jan 16 '15 at 19:34





            You can also use openssl to generate the encrypted password. For example: usermod --password $(echo my_new_password | openssl passwd -1 -stdin) USERNAME

            – Eric Smith
            Jan 16 '15 at 19:34













            Three years too late. I couldn't make the answer @EricSmith, but I did discover a simpler version of the command that did work: usermod --password $(openssl passwd -1 password) username

            – BoCoKeith
            Nov 29 '18 at 15:36






            Three years too late. I couldn't make the answer @EricSmith, but I did discover a simpler version of the command that did work: usermod --password $(openssl passwd -1 password) username

            – BoCoKeith
            Nov 29 '18 at 15:36














            9














            You should look at the chpasswd command (if available in your linux flavor):



            echo 'userid:newpasswd' | chpasswd


            Or, you can cat a file listing userid:passwd for each account on a separate line.



            That's it.






            share|improve this answer

























            • this worked for me in Dockerfile

              – Vishrant
              Jan 27 at 18:58















            9














            You should look at the chpasswd command (if available in your linux flavor):



            echo 'userid:newpasswd' | chpasswd


            Or, you can cat a file listing userid:passwd for each account on a separate line.



            That's it.






            share|improve this answer

























            • this worked for me in Dockerfile

              – Vishrant
              Jan 27 at 18:58













            9












            9








            9







            You should look at the chpasswd command (if available in your linux flavor):



            echo 'userid:newpasswd' | chpasswd


            Or, you can cat a file listing userid:passwd for each account on a separate line.



            That's it.






            share|improve this answer















            You should look at the chpasswd command (if available in your linux flavor):



            echo 'userid:newpasswd' | chpasswd


            Or, you can cat a file listing userid:passwd for each account on a separate line.



            That's it.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 2 '14 at 21:22









            Eric Carvalho

            42.2k17115147




            42.2k17115147










            answered Jan 2 '14 at 21:02









            AllanAllan

            9111




            9111












            • this worked for me in Dockerfile

              – Vishrant
              Jan 27 at 18:58

















            • this worked for me in Dockerfile

              – Vishrant
              Jan 27 at 18:58
















            this worked for me in Dockerfile

            – Vishrant
            Jan 27 at 18:58





            this worked for me in Dockerfile

            – Vishrant
            Jan 27 at 18:58











            1














            Inspired by Eric Smith's idea, combining openssl passwd and usermod -p command worked. Generate hashed value of password along with salt value.



            $ openssl passwd -1 -salt 5RPVAd clear-text-passwd43
            $1$5RPVAd$vgsoSANybLDepv2ETcUH7.


            Then, copy the encrypted string to usermod. Make sure to wrap it with single quote.



            $ usermod -p '$1$5RPVAd$vgsoSANybLDepv2ETcUH7.' root


            Check it out in shadow file.



            $ grep root /etc/shadow
            root:$1$5RPVAd$vgsoSANybLDepv2ETcUH7.:17774:0:99999:7:::





            share|improve this answer





























              1














              Inspired by Eric Smith's idea, combining openssl passwd and usermod -p command worked. Generate hashed value of password along with salt value.



              $ openssl passwd -1 -salt 5RPVAd clear-text-passwd43
              $1$5RPVAd$vgsoSANybLDepv2ETcUH7.


              Then, copy the encrypted string to usermod. Make sure to wrap it with single quote.



              $ usermod -p '$1$5RPVAd$vgsoSANybLDepv2ETcUH7.' root


              Check it out in shadow file.



              $ grep root /etc/shadow
              root:$1$5RPVAd$vgsoSANybLDepv2ETcUH7.:17774:0:99999:7:::





              share|improve this answer



























                1












                1








                1







                Inspired by Eric Smith's idea, combining openssl passwd and usermod -p command worked. Generate hashed value of password along with salt value.



                $ openssl passwd -1 -salt 5RPVAd clear-text-passwd43
                $1$5RPVAd$vgsoSANybLDepv2ETcUH7.


                Then, copy the encrypted string to usermod. Make sure to wrap it with single quote.



                $ usermod -p '$1$5RPVAd$vgsoSANybLDepv2ETcUH7.' root


                Check it out in shadow file.



                $ grep root /etc/shadow
                root:$1$5RPVAd$vgsoSANybLDepv2ETcUH7.:17774:0:99999:7:::





                share|improve this answer















                Inspired by Eric Smith's idea, combining openssl passwd and usermod -p command worked. Generate hashed value of password along with salt value.



                $ openssl passwd -1 -salt 5RPVAd clear-text-passwd43
                $1$5RPVAd$vgsoSANybLDepv2ETcUH7.


                Then, copy the encrypted string to usermod. Make sure to wrap it with single quote.



                $ usermod -p '$1$5RPVAd$vgsoSANybLDepv2ETcUH7.' root


                Check it out in shadow file.



                $ grep root /etc/shadow
                root:$1$5RPVAd$vgsoSANybLDepv2ETcUH7.:17774:0:99999:7:::






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 1 hour ago









                nyg

                1033




                1033










                answered Aug 31 '18 at 21:29









                Joon ByunJoon Byun

                111




                111





















                    0














                    You should use password aging, and set the users so that they must change their password on the first login. See this article.






                    share|improve this answer























                    • These intended to be FTP-only accounts, but good advice. ;)

                      – Jake Petroules
                      Nov 18 '11 at 22:49















                    0














                    You should use password aging, and set the users so that they must change their password on the first login. See this article.






                    share|improve this answer























                    • These intended to be FTP-only accounts, but good advice. ;)

                      – Jake Petroules
                      Nov 18 '11 at 22:49













                    0












                    0








                    0







                    You should use password aging, and set the users so that they must change their password on the first login. See this article.






                    share|improve this answer













                    You should use password aging, and set the users so that they must change their password on the first login. See this article.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 18 '11 at 21:37









                    waltinatorwaltinator

                    22.7k74169




                    22.7k74169












                    • These intended to be FTP-only accounts, but good advice. ;)

                      – Jake Petroules
                      Nov 18 '11 at 22:49

















                    • These intended to be FTP-only accounts, but good advice. ;)

                      – Jake Petroules
                      Nov 18 '11 at 22:49
















                    These intended to be FTP-only accounts, but good advice. ;)

                    – Jake Petroules
                    Nov 18 '11 at 22:49





                    These intended to be FTP-only accounts, but good advice. ;)

                    – Jake Petroules
                    Nov 18 '11 at 22:49

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f80444%2fhow-to-set-user-passwords-using-passwd-without-a-prompt%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Möglingen Índice Localización Historia Demografía Referencias Enlaces externos Menú de navegación48°53′18″N 9°07′45″E / 48.888333333333, 9.129166666666748°53′18″N 9°07′45″E / 48.888333333333, 9.1291666666667Sitio web oficial Mapa de Möglingen«Gemeinden in Deutschland nach Fläche, Bevölkerung und Postleitzahl am 30.09.2016»Möglingen

                    Virtualbox - Configuration error: Querying “UUID” failed (VERR_CFGM_VALUE_NOT_FOUND)“VERR_SUPLIB_WORLD_WRITABLE” error when trying to installing OS in virtualboxVirtual Box Kernel errorFailed to open a seesion for the virtual machineFailed to open a session for the virtual machineUbuntu 14.04 LTS Virtualbox errorcan't use VM VirtualBoxusing virtualboxI can't run Linux-64 Bit on VirtualBoxUnable to insert the virtual optical disk (VBoxguestaddition) in virtual machine for ubuntu server in win 10VirtuaBox in Ubuntu 18.04 Issues with Win10.ISO Installation

                    Torre de la Isleta Índice Véase también Referencias Bibliografía Enlaces externos Menú de navegación38°25′58″N 0°23′02″O / 38.43277778, -0.3838888938°25′58″N 0°23′02″O / 38.43277778, -0.38388889Torre de la Illeta de l’Horta o Torre Saleta. Base de datos de bienes inmuebles. Patrimonio Cultural. Secretaría de Estado de CulturaFicha BIC Torre de la Illeta de l’Horta. Dirección General de Patrimonio Cultural. Generalitat ValencianaLugares de interés. Ayuntamiento del CampelloTorre de la Isleta en CastillosNet.org