Visit Our UNIX and Linux User Community


Wants to create 3 users in 400 servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wants to create 3 users in 400 servers
# 1  
Old 12-07-2011
Error 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

Code:
#!/usr/bin/ksh
for server in `cat /tmp/servers`
do
   echo "servername = $server"
   ssh $server 'sudo /usr/sbin/useradd -d /home/user -m -c "DBA Team at `date +%d-%m-%Y`" -s /usr/bin/ksh user' exit
done

this command showing the error if i add the passwd cmd in this script
Code:
ssh $server 'sudo /usr/sbin/useradd -d /home/user -m -c "DBA Team at `date +%d-%m-%Y`" -s /usr/bin/ksh user; sudo passwd user' exit

Moderator's Comments:
Mod Comment Please use code tags!

Last edited by zaxxon; 12-07-2011 at 04:23 AM.. Reason: code tags, see PM
# 2  
Old 12-07-2011
I would suggest centralized user management with NIS or LDAP.
# 3  
Old 12-07-2011
I dont have permission
# 4  
Old 12-07-2011
Bug

use openssl to generate a md5 based bsd password and pass it to useradd

Code:
PASSWORD=$(openssl passwd -1 plainpassword)
useradd -p'${PASSWORD}' -d /home/user and the list goes on

# 5  
Old 12-07-2011
Solaris and AIX dont have this option
# 6  
Old 12-11-2011
Quote:
Originally Posted by G0kulakrishnan
I dont have permission
Then ask for that permission to be granted. "useradd" doesn't allow to set a user's password for security reasons. NIS and LDAP are designed to handle such requirements.

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. Shell Programming and Scripting

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: 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?... (7 Replies)
Discussion started by: jennie28n
7 Replies

4. Shell Programming and Scripting

Create multiple users with individual passwords to users

hi, i am new to shell scripts i write a shell script to create multiple users but i need to give passwords to that users while creating users, command to write this script (1 Reply)
Discussion started by: DONFOX
1 Replies

5. Shell Programming and Scripting

automatically create password and expand it to other servers

Im a new system administrator. I have to create a script to put in crontab to change periodically root password and didtribute it to other servers. I searched the posted threads but I didn't find my answer. I would like to do this using ssh and trusted keys. Can anyone help me? Thanks. Aldina (0 Replies)
Discussion started by: Alrica
0 Replies

6. Shell Programming and Scripting

Create new users

Hi , i would like to create a new user over unix ,which are these commands to used and which are the directories to handler? Thank you (3 Replies)
Discussion started by: dimitris
3 Replies

7. Filesystems, Disks and Memory

how to create same paritations from same SAN disk on two linux servers

Hi All, Storage team assigned same SAN disk on two servers how to create same paritations from same SAN disk on two linux servers may i know options & procedure. But here one server writing on SAN disk and another server reading other files from SAN disks Thanks in advance (1 Reply)
Discussion started by: kurva
1 Replies

8. Solaris

apache ErrorDocument 400 /cgi-bin/400.cgi

Hi All, Sorry if the question is trivial for you but, I am new to Apache (2.0.63) and am trying to figure out how to display my 400.cgi. Here is what I have in httpd.conf servername testing DocumentRoot "/usr/local/apache2/htdocs" ErrorDocument 400 /cgi-bin/badrequest-400.cgi Here is... (0 Replies)
Discussion started by: afadaghi
0 Replies

9. 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

10. 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

Featured Tech Videos