Useradd on 200 servers from one server.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Useradd on 200 servers from one server.
# 1  
Old 04-30-2014
Useradd on 200 servers from one server.

I have a list of around 250 machines(IPs).

I have few lines of task on each machine like adding users.
I don't want to logon to each machine and then change.

Can anybody help me getting logic to do it from one machine through SSH, where I can hardcode the password as well as other tasks.
# 2  
Old 04-30-2014
Have you tried somethin like clusterssh? Altough more than 200 servers are a lot even with a tool like that.
This User Gave Thanks to stdlib For This Post:
# 3  
Old 04-30-2014
You can use SSH to execute commands remotely, have a look at the manual. You'll need to use either expect or sshpass to parse the password. In any case, it's always better to connect using an ssh-key.
# 4  
Old 04-30-2014
Quote:
Originally Posted by nixhead
I have a list of around 250 machines(IPs).

I have few lines of task on each machine like adding users.
While this won't help for all tasks you might want to achieve, you should consider some centralized administrative repository for user management, like NIS or LDAP. Adding or modifying user's account would then need to be done just once. Not to mention password synchronization.
This User Gave Thanks to jlliagre For This Post:
# 5  
Old 04-30-2014
If you put the public SSH key on each of the servers, then you will be able to have password-less authentication to run the commands. Do you know how to generate the keys and what to do with them?

If you are running as the root user, then you will need to make sure that the /etc/ssh/sshd.conf configuration file permits root login. There are a number of options to consider and balance against the risks.


I'm afraid that there is no easy way to get them onto each server - it will be a manual task, but the investment of time in a one off action.

Note
When you are adding your users, you will need to make sure that their UID is unique too. Some servers will object if you try to add a user with a specific UID that already exists. You could get away with not specifying the UID, but then if you are NFS sharing files (or moving them keeping original permissions) then you will all sorts of problems because files are owned by the UID not the alphabetic userid.


I agree with jlliagre that you would be better to use NIS (historically also known as YP) or LDAP. Once set up, that would cut down the administration effort.




Robin
This User Gave Thanks to rbatte1 For This Post:
# 6  
Old 05-05-2014
Thanks All for your contribution, especially rbatte1
I tried expect, but it's tricky to code, I heard about Func, it's easier to do.
I will try Func.

---------- Post updated at 05:08 AM ---------- Previous update was at 05:08 AM ----------

LDAP or NIS is not an option in this case Smilie
# 7  
Old 05-05-2014
If it was me, I would write a PHP script to do this. Basically you would have a configuration file with the hostnames and other required information; then you can write a PHP script to read the configuration file, do the tasks on the servers, and log any errors or the results.

For SSH from PHP you might consider phplibsec

With a PHP solution, you could then create a secure web-interface to help with the tasks.
This User Gave Thanks to Neo For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Scripting in one server to apply other servers?

Hey everyone, I have got 100 different servers(all linux and same version).One of them admin server can reach to others and their structures are same.For example I want to change OS dates and weblogic(java dates) for the timezone project.But I do not want to deal with each one separately.I want... (10 Replies)
Discussion started by: daggerphobia_
10 Replies

2. Solaris

Solaris 11 AI Server Backup existing servers?

Hey Guys i've got a question about the AI Server. Is there any possibility to backup existing servers to reinstall them automaticly by using the AI Server? Regards Marcus (3 Replies)
Discussion started by: Marcusg562
3 Replies

3. UNIX for Dummies Questions & Answers

Ssh not working to one server from any of the servers

Hello, I tried ssh in debug mode and below is the debug snippet.ssh to a host is not working from any of the hosts No credentials cache found debug1: Miscellaneous failure No credentials cache found debug1: Next authentication method: publickey debug1: Offering RSA public key:... (7 Replies)
Discussion started by: Vishal_dba
7 Replies

4. Shell Programming and Scripting

Executing certain commands on different servers from one server only

hi I wish to fire certain set of commands on different servers using single script on one of the server. The problem is that these servers only allow ssh session. telnet to these systems is blocked. Is there any way i can do this as rsh does not works. Regards Rochit (7 Replies)
Discussion started by: rochitsharma
7 Replies

5. AIX

Servers still querying old DNS server?

Hello, I've created new DNS servers and changed all of the clients /etc/resolv.conf to point to them, but when I check the old DNS logs, I see that the clients are still querying it. Does anybody know why? thanks, (2 Replies)
Discussion started by: ctcuser
2 Replies

6. Shell Programming and Scripting

scp between 2 servers - invoked at 3rd server

I have a couple of servers that can't see each other and need to copy files from one to the other. I try to invoke scp from a 3rd server that can see both servers - get error msgs that are cryptic. from server C I can do scp user@serverA:~/file . scp file user@serverB:~ but if I try to... (2 Replies)
Discussion started by: bigjohn-nj
2 Replies

7. Solaris

Booting Up Servers from the Terminal Server.

All, I have a problem with booting up of servers. I am involved in application programming(Perl/Shell), but don't have much hardware knowledge about the Sun Solaris Server's we use. Our Development Servers are located at a remote place from the Development Centre. Every time there is a Power... (1 Reply)
Discussion started by: rahulrathod
1 Replies

8. UNIX for Dummies Questions & Answers

win 200 server + Redhat 9 + FreeBSD 5.1 ?

hi all : i am new to unix and linux world , my experience is near zero, so i am seeking your help to maintain a learning environment to try to catch up with linux and unix in the same time , furthermore win 2000 server is a must for my current job , so what do u think , can this triple boot... (1 Reply)
Discussion started by: behmoth
1 Replies
Login or Register to Ask a Question