I need to add 30 users to 50 servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I need to add 30 users to 50 servers
# 1  
Old 09-24-2013
I need to add 30 users to 50 servers

Hi Y'all,

I need help adding 30 users to 50 servers.

Is there a way to automate this?

I'm using this command:
Code:
sudo mkuser pgrp=srvadm gecos=Spears, Brittney auditclasses=ALL sugroups=system,security user01

But I'm doing it per user, per server...HOW CAN I MAKE THIS EASIER? Smilie

JN

Last edited by Scott; 09-24-2013 at 06:10 PM.. Reason: Code tags
# 2  
Old 09-24-2013
Perhaps NIS is what you want to use here.

This also helps keep the accounts in sync (eg if password is changed on 1 server it changes for all).

If your likely to need to run other commands on all these 50 servers I'd suggest getting passwordless ssh working between your box and the 50. you can then do something like:

Code:
for server in sever1 server2 server3
do
    ssh $server sudo mkuser pgrp=srvadm gecos=Spears, Brittney auditclasses=ALL sugroups=system,security user01
done

# 3  
Old 09-24-2013
... and then run a while loop as the ssh remote command, reading user info from a file containing all 30 users' details, e.g. like
Code:
ssh $server "while read A; do ls \$A; done" <file

# 4  
Old 09-24-2013
I need to add 30 users to 50 servers

Hi Thanks for the replies!

re: NIS

What is this?

Currently, I need to ssh to the server, then run the sudo mkuser command...

So instead I would input this for each server?:
ssh $server sudo mkuser pgrp=srvadm gecos=Spears, Brittney auditclasses=ALL sugroups=system,security user01
done

what is the difference from just doing it 1 by 1?

---------- Post updated at 04:26 PM ---------- Previous update was at 04:25 PM ----------

I'm not sure how to decifer this:

Code:
ssh $server "while read A; do ls \$A; done" <file


Last edited by Scott; 09-24-2013 at 07:55 PM.. Reason: Please use code tags
# 5  
Old 09-24-2013
That is an example doing a directory listing of those remote filenames that are contained in file. If you list your users' data in file, you can read the respective data and use these variables in the mkuser command, looping until file end.
# 6  
Old 09-24-2013
Quote:
Originally Posted by jennie28n
re: NIS

What is this?
For me, the first Google result is relevant.

Are you going to modify a user's account on all 50 machines if that user needs their password changed? Or if a user needs to be disabled? Or if a user needs to be added or deleted from a group? Or if ....

If you share with us the big picture of what's going on, someone might be able to give you well-informed advice.

Regards,
Alister
# 7  
Old 09-24-2013
NIS: Network Information Service

Quote:
A NIS/YP system maintains and distributes a central directory of user and group information, hostnames, e-mail aliases and other text-based tables of information in a computer network. For example, in a common UNIX environment, the list of users for identification is placed in /etc/passwd, and secret authentication hashes in /etc/shadow. NIS adds another “global” user list which is used for identifying users on any client of the NIS domain.
what is the difference from just doing it 1 by 1?

You can build script that adds all 20 users, and then copy/execute the script on all 50 servers using ssh. This will reduce your effort and eliminate the possibility of typos causing certain servers to have different setups.

But again if the users need to be kept in sync form this date forward NIS/YP is the preferred solution.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to delete users in the servers

Hi Team, Hope you are doing good.I am new to scripting.I have a requirement of deleting around 10 users in 100 servers.It is very time consuming by logging into each servers and delete the user.Here I have redhat 6 ,Suse linux 10&11 environment servers. In one set of servers I have... (5 Replies)
Discussion started by: muraliinfy04
5 Replies

2. Shell Programming and Scripting

Script to add new users to a group on multiple servers using SSH

Hi Experts, I am new to scripting. We have around 400 Linux servers in our environment. I want to add a new user to a perticular group on all the servers using SSH. Requirements: 1) Need to take the server names from a text file. 2) Login into each server and check whether perticular... (1 Reply)
Discussion started by: Satya1983
1 Replies

3. AIX

Script to add .profile from one server to all other servers in the network

Hi experts, I am an AIX/Unix admin in my company. I have been asked by one user to distribute .profile from one server to all other servers in the network. This is what she has asked me: "Is there a way for me to save and use one .profile that I have personalized with aliases for all my... (4 Replies)
Discussion started by: uzair_rock
4 Replies

4. Shell Programming and Scripting

Wants to create 3 users in 400 servers

I wants to create 3 users and set password for the users in 400 servers. I can run this script without error. If wants to set the password in the same command it is not working. Like that i have to create 3 users #!/usr/bin/ksh for server in `cat /tmp/servers` do echo "servername =... (5 Replies)
Discussion started by: G0kulakrishnan
5 Replies

5. Shell Programming and Scripting

add second field of two files on different servers

Hi I have one file placed at one server whose sample as follows: 57272 28 56767 0 57575 4 58888 6 53030 26 54242 0 56060 0 And another file at different server whose sample data as follows: 57272 22 56767 0 57575 1 58888 2 53030 13 (9 Replies)
Discussion started by: poweroflinux
9 Replies

6. Shell Programming and Scripting

Mass add users

Anyone has a script or something that can do this? I have a list of about 500 users and I need to add them to an AIX box. The profiles should have "Full Name" and "User Name". (2 Replies)
Discussion started by: bbbngowc
2 Replies

7. Solaris

How to add multiple users

HI, 1.I want to add multiple users at a same time. How to achive this , since useradd will add only one user at a time,. 2.Also let me know how to install a software in a group of machines where the machines are not configured as zones (1 Reply)
Discussion started by: rogerben
1 Replies

8. UNIX for Advanced & Expert Users

Application Servers Installation and Users

Hi, When most of the server applications get installed, they create their own user. I believe this is to not use the "root" account. For example, Apache when installed creates a user called "apache". And the directories which it uses are all owned by this user. This seems to be the... (2 Replies)
Discussion started by: srikanths
2 Replies

9. Shell Programming and Scripting

script to create users on many servers

Hi all, working on script to create a user acct on all our servers. for i in `cat $host_file`; do ssh $i /usr/bin/sudo /usr/bin/mkuser id='bpadm' gecos='NetBackup Admin' 2>&1 >> $log done error i get is: 3004-692 Error changing "id" to "bpadm" : Value is invalid. I have tried this in... (1 Reply)
Discussion started by: dnidiffer
1 Replies

10. Shell Programming and Scripting

User add on multiple servers

I have 85 Unix servers & I need to add single user ID on multiple servers at same time Can anyone help in this? I have written one script for single servers.same I need to user for multiple servers #!/bin/sh echo Enter user login ID read loginID echo Enter Group ID read GroupID ... (6 Replies)
Discussion started by: sandeep_pan
6 Replies
Login or Register to Ask a Question