1752572 Members
4609 Online
108788 Solutions
New Discussion юеВ

Re: Script to Push Users

 
SOLVED
Go to solution
KPS
Super Advisor

Script to Push Users

Hi,

I'm wondering if someone might have a script that they would like to share that would be handy to push users, home directories, and profiles to other hosts? We can't run NIS and that is not an option for us.

What I would ideally like to do is have one of our HP-UX servers be the initial place that users get created and then run a script to push the user out once the user is created on this first server. Method of push may be ssh or maybe rsync? Any ideas, examples, or suggestions would be very greatly appreciated.

Thanks!!!!
KPS
7 REPLIES 7
Rita C Workman
Honored Contributor

Re: Script to Push Users

Here's one that someone here wrote once:

Create file with a list of all your hostnames. Then edit whats in < -- > in the line below for each new useradd.

This is for one user at a time.

for h in `cat hostlist`
do
echo $h":\c"
remsh $h -n /usr/sbin/useradd -u -g -d /home/$b -s /bin/ksh -c -m -k
/etc/ $b
echo "Will add user $b to $h "
remsh $h -n /usr/bin/passwd -f -n 56 -x 7 $b
echo "User $b has password set on $h"
done
done

Hope this helps, watch out for typos
Rgrds,
Rita
Rita C Workman
Honored Contributor

Re: Script to Push Users

oops, there's a piece out of that old script.

Create a file with the new login id's too.
Then it should read more like this at the top:

for h in `cat hostlist`
do
for b in `cat /scripts/login_id.lis`
do
echo $h":\c"
echo $b
(and so forth....)

....now that $b variable makes sense.



/rcw
Rick Garland
Honored Contributor
Solution

Re: Script to Push Users

Here is a suggestion. Modify to your environment. Set for remsh now but you can make the necessary changes for ssh.

This works in 2 parts. 1st part gathers the info and 2nd part executes the adduser command on the remote systems.

No NIS is involved but we did make sure that the UIDs were the same across all other systems.

As always, carefully review and use at your risk.
Rick Garland
Honored Contributor

Re: Script to Push Users

The previous post has the 2nd part of the process. Here is the 1st part that resides on the localhost.

KPS
Super Advisor

Re: Script to Push Users

Hi Rick,

Thanks for your help, but the first of the 2 attachments didn't seem like it came over in the right format. Could you send again?

Thanks,
KPS
Bill Hassell
Honored Contributor

Re: Script to Push Users

Rick's attachments are correct, but Notepad does not understand Unix records. Save the file rather than opening it with Notepad, then open the file using Wordpad or Word. Then copy and paste the results into Notepad or save the file with a .txt extension. Unix text files have just LF at the end of the line which confuses Notepad. Word and Wordpad will treat the LF as a soft return and display the text correctly.


Bill Hassell, sysadmin
KPS
Super Advisor

Re: Script to Push Users

Thanks everyone. Rick I think I like the samples you provided and will use this method and prepare the scripts to use ssh and scp in our environment.

Thanks so much!

KPS