RE: creating remoteuser

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



for some reason, my e-mail editor keeps deleting newlines from my e-mails.
The 'do'statement in the 'while' loop should be on a new line or else you
would have to precede it by a semi-colon.

Michael 

> -----Original Message-----
> From: redhat-list-bounces@xxxxxxxxxx 
> [mailto:redhat-list-bounces@xxxxxxxxxx] On Behalf Of Michael Velez
> Sent: Thursday, March 17, 2005 8:56 AM
> To: 'darshan jadav'; 'General Red Hat Linux discussion list'
> Subject: RE: creating remoteuser
> 
>  
> 
> > -----Original Message-----
> > From: redhat-list-bounces@xxxxxxxxxx
> > [mailto:redhat-list-bounces@xxxxxxxxxx] On Behalf Of darshan jadav
> > Sent: Thursday, March 17, 2005 7:44 AM
> > To: redhat-list@xxxxxxxxxx
> > Subject: creating remoteuser
> > 
> > Hi all
> > 
> > I m making script to automate remote server user creation, 
> using sudo, 
> > this is my sript, something is not working out or parts missing, am 
> > very new 2 bash scripting, plz help Am not able to complete the 
> > script, plz tell me where i am going wrong...
> > 
> > Thanks a lot
> > 
> > --------------------------------------------------------------
> > -------------------------------------------------------
> > echo Checking for the user file
> > echo
> > grep ^$1: /home/dj/list > /dev/null 2>&1 if [ "$?" -eq 0 ]; then
> >         echo " User file not found" >&2
> >         exit 1
> > fi
> > echo
> > echo -e "Enter Hostname:"
> > read -e HOST
> > PASSWORD="test"
> > NEW_USERS="/home/dj/list"
> > cat ${NEW_USER}|\
> > while read USER GROUP PASSWORD FULL NAME do #echo  "Enter Hostname"
> > #read -e HOST
> > ssh $HOST |\
> > sudo /usr/sbin/useradd -G ${GROUP} -p ${PASSWORD} ${USER} 
> -c "${FULL} 
> > ${NAME}"
> > $PASSWORD
> > done
> > --------------------------------------------------------------
> > ---------------------------------------------------------
> > 
> > --
> > redhat-list mailing list
> > unsubscribe 
> mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
> > https://www.redhat.com/mailman/listinfo/redhat-list
> > 
> 
> There are several issues in the script.  I took a stab at a 
> few below.  I haven't put in the sudo code as I am not a 
> proponent of including passwords in script files.  You may 
> want to have a public/private key pair between the two root 
> id's on both machines.  That would require you to have a key 
> without a passphrase, which, for root, is not ideal either.
> 
> I'll let the security gurus handle that one.
> 
> Here is a draft script rewritten:
> 
> --- Start of script ---
> #!/bin/bash
> 
> echo "Checking for user file..."
> if [[ ! -e /home/dj/list ]]
> then
> 	echo "User file not found" >& 2
> 	exit 1
> fi
> 
> echo -n "Enter Hostname: "
> read HOST
> 
> 3</home/dj/list
> 
> while read -u 3 USER GROUP PASSWORD FULL NAME do
> 	ssh $HOST ...
> 	...
> done
> --- End of script ---
> 
> Hope this helps,
> Michael
> 
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
> 

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux