Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to create a new user account with password in more than 200 systems. What will be the easiest way? Is it possible to do this task via bash script or perl script?

share|improve this question
Have a look at the commands addgroup and adduser. – Paddy Landau Jul 21 '12 at 18:58
up vote 4 down vote accepted

Generate the password with perl perl -e 'print crypt("passwd", "passwd");'.

Then just use a bash script to call useradd via ssh on each server (assuming you already setup ssh keys for password-less login, otherwise this will get old, fast)

pass=$(perl -e 'print crypt("passwd", "passwd");')
for srv in $(cat server.list); do
   ssh $srv useradd -m -p "$pass" username

and check the manpage for the useradd command Manpage icon.

share|improve this answer

I would suggest to use ansible if you want to create a user account across a large number of servers. Ofcourse, it's not limited to just user accounts and it's very easy to get setup and started with using ansible. The documentation is quite nice!

All you do is add all your 200 servers into an inventory file and run a simple command to create all the accounts. Take a look at this example of adding a user.

share|improve this answer
Could you share here an example, on using ansible with ssh private key.. – karthick87 Jan 16 '13 at 7:51
As part of your initial setup of ansible you will be adding your ssh private key to ssh-agent, see the Getting Started section. The example itself would just be that one line command as shown in the example link I have given above. viz. ansible all -m user -a "name=test1 comment=TestUser1 group=users shell=/bin/bash" – Amar Jan 17 '13 at 12:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.