What is the fastest way to create multiple thousands of users on a system?












0















I need to create multiple thousands of users on a linux system. Currently I use the newusers command with a file as the source for all the users. The file contains around 10000 users. Running



$ newusers /tmp/users.txt


works and creates the users, but it takes very long to complete.
The users don't need a shell, a home directory or a password. They also don’t need to be able to login. The users are needed for ssh tunnel purposes.



Is there a way to do this more quick?










share|improve this question









New contributor




p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Probably not an answer: import them into LDAP.

    – Jeff Schaller
    1 hour ago











  • This is really not an answer since I need the users on the system for ssh purposes. I’ll update the question thank you!

    – p0fi
    1 hour ago











  • That is the best advice for that number of users actually. Setting ldap for authentication

    – Rui F Ribeiro
    1 hour ago













  • I don’t need authentification other than a ssh key

    – p0fi
    1 hour ago






  • 1





    Have you thought about doing it the hard way? Take your user list, add the passwd fields to each user, then append that to the passwd file. You then make their homes using the original file with their list of names, copying /etc/skel over if needed. Absolutely not sure if that is faster than newusers.

    – number9
    57 mins ago
















0















I need to create multiple thousands of users on a linux system. Currently I use the newusers command with a file as the source for all the users. The file contains around 10000 users. Running



$ newusers /tmp/users.txt


works and creates the users, but it takes very long to complete.
The users don't need a shell, a home directory or a password. They also don’t need to be able to login. The users are needed for ssh tunnel purposes.



Is there a way to do this more quick?










share|improve this question









New contributor




p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    Probably not an answer: import them into LDAP.

    – Jeff Schaller
    1 hour ago











  • This is really not an answer since I need the users on the system for ssh purposes. I’ll update the question thank you!

    – p0fi
    1 hour ago











  • That is the best advice for that number of users actually. Setting ldap for authentication

    – Rui F Ribeiro
    1 hour ago













  • I don’t need authentification other than a ssh key

    – p0fi
    1 hour ago






  • 1





    Have you thought about doing it the hard way? Take your user list, add the passwd fields to each user, then append that to the passwd file. You then make their homes using the original file with their list of names, copying /etc/skel over if needed. Absolutely not sure if that is faster than newusers.

    – number9
    57 mins ago














0












0








0








I need to create multiple thousands of users on a linux system. Currently I use the newusers command with a file as the source for all the users. The file contains around 10000 users. Running



$ newusers /tmp/users.txt


works and creates the users, but it takes very long to complete.
The users don't need a shell, a home directory or a password. They also don’t need to be able to login. The users are needed for ssh tunnel purposes.



Is there a way to do this more quick?










share|improve this question









New contributor




p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I need to create multiple thousands of users on a linux system. Currently I use the newusers command with a file as the source for all the users. The file contains around 10000 users. Running



$ newusers /tmp/users.txt


works and creates the users, but it takes very long to complete.
The users don't need a shell, a home directory or a password. They also don’t need to be able to login. The users are needed for ssh tunnel purposes.



Is there a way to do this more quick?







linux users performance






share|improve this question









New contributor




p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 1 hour ago







p0fi













New contributor




p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 hours ago









p0fip0fi

1012




1012




New contributor




p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






p0fi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    Probably not an answer: import them into LDAP.

    – Jeff Schaller
    1 hour ago











  • This is really not an answer since I need the users on the system for ssh purposes. I’ll update the question thank you!

    – p0fi
    1 hour ago











  • That is the best advice for that number of users actually. Setting ldap for authentication

    – Rui F Ribeiro
    1 hour ago













  • I don’t need authentification other than a ssh key

    – p0fi
    1 hour ago






  • 1





    Have you thought about doing it the hard way? Take your user list, add the passwd fields to each user, then append that to the passwd file. You then make their homes using the original file with their list of names, copying /etc/skel over if needed. Absolutely not sure if that is faster than newusers.

    – number9
    57 mins ago














  • 1





    Probably not an answer: import them into LDAP.

    – Jeff Schaller
    1 hour ago











  • This is really not an answer since I need the users on the system for ssh purposes. I’ll update the question thank you!

    – p0fi
    1 hour ago











  • That is the best advice for that number of users actually. Setting ldap for authentication

    – Rui F Ribeiro
    1 hour ago













  • I don’t need authentification other than a ssh key

    – p0fi
    1 hour ago






  • 1





    Have you thought about doing it the hard way? Take your user list, add the passwd fields to each user, then append that to the passwd file. You then make their homes using the original file with their list of names, copying /etc/skel over if needed. Absolutely not sure if that is faster than newusers.

    – number9
    57 mins ago








1




1





Probably not an answer: import them into LDAP.

– Jeff Schaller
1 hour ago





Probably not an answer: import them into LDAP.

– Jeff Schaller
1 hour ago













This is really not an answer since I need the users on the system for ssh purposes. I’ll update the question thank you!

– p0fi
1 hour ago





This is really not an answer since I need the users on the system for ssh purposes. I’ll update the question thank you!

– p0fi
1 hour ago













That is the best advice for that number of users actually. Setting ldap for authentication

– Rui F Ribeiro
1 hour ago







That is the best advice for that number of users actually. Setting ldap for authentication

– Rui F Ribeiro
1 hour ago















I don’t need authentification other than a ssh key

– p0fi
1 hour ago





I don’t need authentification other than a ssh key

– p0fi
1 hour ago




1




1





Have you thought about doing it the hard way? Take your user list, add the passwd fields to each user, then append that to the passwd file. You then make their homes using the original file with their list of names, copying /etc/skel over if needed. Absolutely not sure if that is faster than newusers.

– number9
57 mins ago





Have you thought about doing it the hard way? Take your user list, add the passwd fields to each user, then append that to the passwd file. You then make their homes using the original file with their list of names, copying /etc/skel over if needed. Absolutely not sure if that is faster than newusers.

– number9
57 mins ago










1 Answer
1






active

oldest

votes


















0














Here's the way I would do it, since they are all local accounts:

1. Determine the range of userIDs

2. Determine the group ID(s) for the users

3. Write a script that will:

a. create a temporary password file filled with the information you need

${username}:x:${userid}:${groupid}::${homedir}:/bin/false

b. create a temporary shadow file with the information you need

${username}:!!:1:0:99999:7:::

4. append the temporary shadow file to /etc/shadow and the temporary password file to /etc/passwd



NB1: I am not sure if the ${homedir} can be blank, /dev/null, or something else

NB2: If you are not using /etc/shadow, replace the :x: in passwd with :!!:



That ought to be fairly quick (however long it takes to create the temp files), quickly update passwd & shadow fileswithout any other password hashing, UID searching, etc.






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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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
    });


    }
    });






    p0fi is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f506150%2fwhat-is-the-fastest-way-to-create-multiple-thousands-of-users-on-a-system%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Here's the way I would do it, since they are all local accounts:

    1. Determine the range of userIDs

    2. Determine the group ID(s) for the users

    3. Write a script that will:

    a. create a temporary password file filled with the information you need

    ${username}:x:${userid}:${groupid}::${homedir}:/bin/false

    b. create a temporary shadow file with the information you need

    ${username}:!!:1:0:99999:7:::

    4. append the temporary shadow file to /etc/shadow and the temporary password file to /etc/passwd



    NB1: I am not sure if the ${homedir} can be blank, /dev/null, or something else

    NB2: If you are not using /etc/shadow, replace the :x: in passwd with :!!:



    That ought to be fairly quick (however long it takes to create the temp files), quickly update passwd & shadow fileswithout any other password hashing, UID searching, etc.






    share|improve this answer




























      0














      Here's the way I would do it, since they are all local accounts:

      1. Determine the range of userIDs

      2. Determine the group ID(s) for the users

      3. Write a script that will:

      a. create a temporary password file filled with the information you need

      ${username}:x:${userid}:${groupid}::${homedir}:/bin/false

      b. create a temporary shadow file with the information you need

      ${username}:!!:1:0:99999:7:::

      4. append the temporary shadow file to /etc/shadow and the temporary password file to /etc/passwd



      NB1: I am not sure if the ${homedir} can be blank, /dev/null, or something else

      NB2: If you are not using /etc/shadow, replace the :x: in passwd with :!!:



      That ought to be fairly quick (however long it takes to create the temp files), quickly update passwd & shadow fileswithout any other password hashing, UID searching, etc.






      share|improve this answer


























        0












        0








        0







        Here's the way I would do it, since they are all local accounts:

        1. Determine the range of userIDs

        2. Determine the group ID(s) for the users

        3. Write a script that will:

        a. create a temporary password file filled with the information you need

        ${username}:x:${userid}:${groupid}::${homedir}:/bin/false

        b. create a temporary shadow file with the information you need

        ${username}:!!:1:0:99999:7:::

        4. append the temporary shadow file to /etc/shadow and the temporary password file to /etc/passwd



        NB1: I am not sure if the ${homedir} can be blank, /dev/null, or something else

        NB2: If you are not using /etc/shadow, replace the :x: in passwd with :!!:



        That ought to be fairly quick (however long it takes to create the temp files), quickly update passwd & shadow fileswithout any other password hashing, UID searching, etc.






        share|improve this answer













        Here's the way I would do it, since they are all local accounts:

        1. Determine the range of userIDs

        2. Determine the group ID(s) for the users

        3. Write a script that will:

        a. create a temporary password file filled with the information you need

        ${username}:x:${userid}:${groupid}::${homedir}:/bin/false

        b. create a temporary shadow file with the information you need

        ${username}:!!:1:0:99999:7:::

        4. append the temporary shadow file to /etc/shadow and the temporary password file to /etc/passwd



        NB1: I am not sure if the ${homedir} can be blank, /dev/null, or something else

        NB2: If you are not using /etc/shadow, replace the :x: in passwd with :!!:



        That ought to be fairly quick (however long it takes to create the temp files), quickly update passwd & shadow fileswithout any other password hashing, UID searching, etc.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 31 mins ago









        Scottie HScottie H

        576




        576






















            p0fi is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            p0fi is a new contributor. Be nice, and check out our Code of Conduct.













            p0fi is a new contributor. Be nice, and check out our Code of Conduct.












            p0fi is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f506150%2fwhat-is-the-fastest-way-to-create-multiple-thousands-of-users-on-a-system%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

            Histoire des bourses de valeurs

            Why is there Russian traffic in my log files?

            Rename multiple files to decrement number in file name?