Operating System - HP-UX
1833875 Members
1885 Online
110063 Solutions
New Discussion

Re: creating new user id in few servers at the same time

 
SOLVED
Go to solution
Joyce Suganthy
Advisor

creating new user id in few servers at the same time

Hi ,

How do i create few user id in few servers (10 servers) at the same time, without using sam?

Thanks

Regards
10 REPLIES 10
Fragon
Trusted Contributor

Re: creating new user id in few servers at the same time

Hi,
1. NIS/NIS+ is prefered if you want;
2. If .rhosts file is correctly configured, you can use "rexec" to achieve it! That is, you can make a script use multiple "rexec" command!

Good luck!
-ux
twang
Honored Contributor
Solution

Re: creating new user id in few servers at the same time

If you have lots of machines to administrate, I believe NIS is the way to go. It's really straight forward to setup, in fact you can do it right from SAM.
A good documentation here on configuring NIS.
http://docs.hp.com/hpux/onlinedocs/B1031-90048/B1031-90048.html
Sridhar Bhaskarla
Honored Contributor

Re: creating new user id in few servers at the same time

Hi Joyce,

I would say write a small script containing series of useradd commands. Copy this script to all your 10 machines (you have to logon to them anyway to setup ssh or .rhosts) and run it. Your script may look like

useradd -u 1000 -g 500 -d /home/user1 -s /usr/bin/ksh -C "User1, xxx-xxx-xxxx" -m -k /etc/skel user1
passwd -df user1

useradd -u 1000 -g 500 -d /home/user2 -s /usr/bin/ksh -C "User2, xxx-xxx-xxxx" -m -k /etc/skel user2
passwd -df user2
useradd -u 1000 -g 500 -d /home/user3 -s /usr/bin/ksh -C "User3, xxx-xxx-xxxx" -m -k /etc/skel user3
passwd -df user3
..

This isn't a real secured way of setting passwords. But you don't have much choice here to get it accomplished in a short time.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Tor-Arne Nostdal
Trusted Contributor

Re: creating new user id in few servers at the same time


If you are using one machine as a master-host and the other as clients, and you're going to use the same username/UID, group/GID, password, home directory etc... (identical setup)

WARNING: This is not recommended if you are keeping separate/individual setup of the machines.

You could grep the user out of the passwd file from the master and add it directly into the passwd file of the client...
I think this is better than copying the file itself.
root@client# remsh master grep newuser >> /etc/passwd


Then create the home directory simply by rcp it from the master to the client

Copy the home directory:
root@client# rcp -pr master:/home/newuser /home/

Copy group file:
not a good idea if you're keeping individual groups on the servers
root@client# rcp -p master:/etc/group /etc/group

Not an elegant way to do it...
I'm trying to become President of the state I'm in...
Donny Jekels
Respected Contributor

Re: creating new user id in few servers at the same time

here is another solution:

use sudo on all your boxes:
in your sudoers file add, commands.

useradd,usermod,/usr/lbin/modprpw,/usr/bin/passwd etc

then use remsh


for x in `cat serverlist`
do
echo $x
remsh $x "sudo /usr/bin/useradd -u 400 -m -k /etc/skel -d /home/ -c "First LAst names" "
remsh $x "sudo /usr/bin/usermod -g users -G "
remsh $x "sudo /usr/lbin/modprpw -x "
done >myresults_with_passwords


hey that will take you less than 2 minutes to complete.


peace
donny




"Vision, is the art of seeing the invisible"
Donny Jekels
Respected Contributor

Re: creating new user id in few servers at the same time

sorry, fogot to add -s /usr/local/bin/bash"

remsh $x "sudo /usr/bin/usermod -g users -G -s /usr/local/bin/bash "
"Vision, is the art of seeing the invisible"
Donny Jekels
Respected Contributor

Re: creating new user id in few servers at the same time

think about creating a flat file with your usernames and uid listed.

user1 1000 adam eve
user2 1001 joe soap
.
.
.
user100 1100 rudy juliani

save the file as "mynewusers"


same for loop with a twist.

for x in `cat serverlist`
do
echo $x
while read loginid uid first last
do
remsh $x "sudo /usr/bin/useradd -u ${uid} -m -k /etc/skel -d /home/${loginid} -s /usr/local/bin/bash -c \"${first} ${last}\" ${loginid}; sudo /usr/lbin/modprpw -x ${loginid}; sudo /usr/bin/usermod -g users ${loginid}"
done done > outputfile

say that does'nt work




















"Vision, is the art of seeing the invisible"
Jack Werner
Frequent Advisor

Re: creating new user id in few servers at the same time

Joyce,

You may want to think ahead and make sure the users' UID numbers are unique accross all Unix nodes on your LAN if you plan to share filesystems via NFS or DCE. The same needs to be insured for the users' GID numbers. I have built a cron'd script that pulls the /etc/passwd file from each NIS server on our network. I then process each /etc/passwd file to produce a "normalized" passwd file. I check this normalized passwd file for logical inconsistencies: A user(identified by his or her login "handle") with more than one UID number assigned to him/her. A UID number possessed by more than one User "handle". Both of these inconsistencies must be resolved to maintain the integrity of the /etc/passwd files among our NIS servers. In our shop a user's handle consists of a single alpha character, followed by their 5 digit employee badge number. We have regular and temporary employees and the alpha character differentiates these. We also provide an editable file, the uid.register, to enable controlling the assignment of unique UID numbers to new users. This register is regenerated daily by the scripts I built. The register contains: User's handle, user's UID, user's name and NIS_Platform.

This may be more than you need, but networks have a way of growing and becoming more complex
i'm retired
Caesar_3
Esteemed Contributor

Re: creating new user id in few servers at the same time

Hello!

For this problem start to use NIS
or you a hard way is to copy the passwd file
to all stations, create directorys and so on.

Run the creation of user on all the station
(you can made a script)

The best is NIS!

Caesar
Chris Vail
Honored Contributor

Re: creating new user id in few servers at the same time

I hate NIS, NIS+ and its variants. We don't use it here.

Here's a quick-and-dirty shell script (real syadmins do it from the prompt!)

for HOST in HOST1 HOST2 HOST3 HOST4......
do
echo $HOST
ssh $HOST "useradd -u UID -g GID -s /bin/sh -d /home/USERNAME -c COMMENT USERNAME"
done

This, of course assumes you have secure shell set up, all your GID's, UID's and such are non-duplicating, and that you're fairly sure this won't break anything (here, it doesn't: we're careful). You could use remsh instead of ssh if necessary.


Chris