Operating System - Linux
1828584 Members
2924 Online
109982 Solutions
New Discussion

User creation in multiple server

 
joinsiva
Advisor

User creation in multiple server

Hi all,

I am facing problem in setting password, when i create a user in multiple server. Can anybody help me in acheiving this in script.

All my servers are linux.

can any body help.

thanks
siva
5 REPLIES 5
RAC_1
Honored Contributor

Re: User creation in multiple server

For such script, you need to have a remsh/ssh enabled for those server. But why create in all server?? Create it in one server and copy those changes to all servers.

1. create user on server 1
2. grep -i user /etc/passwd > /tmp/new-user
3. remsh/ssh if enabled,
4. for i in serverb serverc
do
ssh -q $i 'cp /etc/passwd /etc/passwd.bak'
cat /tmp/new-user | ssh -q $i 'cat - >> /etc/passwd'

This should do it. Backup files before you start. The scipt not tested.
There is no substitute to HARDWORK
Steven E. Protter
Exalted Contributor

Re: User creation in multiple server

Perhaps you might want to implement an LDAP or NIS solution.

Create users on one Linux server, all other users authenticate to that server.

http://www2.itrc.hp.com/service/james/dispDoc.do?docURL=http%3A%2F%2Fsearch.hp.com%2Fredirect.html%3Furl%3Dhttp%253A%2F%2Fdocs.hp.com%2Fen%2FT1417-90009%2Fch05s03.html%26qt%3D%2BHP-UX%2BLdap%2Bconfiguration%26hit%3D1&aid=SEARCH_MANUAL&pil=1&serStr=HP-UX+Ldap+configuration

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ivan Ferreira
Honored Contributor

Re: User creation in multiple server

You should implement LDAP or NIS+ (NIS works good is considered insecure nowdays). With these directory servers, you create users in just one location and is available to all servers that authenticate against the server.

Or, you must copy the /etc/passwd and /etc/shadow entry for every new user on each server (too much effort).
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
joinsiva
Advisor

Re: User creation in multiple server

Hi all,

Thanks for reply. I tried copying the shadow file password string, from one server to other server. It worked in one server with the same password. But in other it has not worked.

Finally, i used mkpasswd command (in linux) which is like modprpw -x (in hpux trusted system ) , which generates a random password for the user. and i captured the text.

still if somebody can help in writing a better script, where we can set our own password, it will be great. becoz copying the string, doesnot working across different version of OS it seems.
joinsiva
Advisor

Re: User creation in multiple server

Hi,

LDAP / NIS , we cannot implement.

With the existing setup is there any way ?.

Is there any perl script which can do this job efficiently ?

thanks
sivakumar p.