Dear all,

I'm doing a script to create a DB user on all machines. I have no way of using sudo. This is for a cross section of sun machines.
i need to ssh to the server, then do a su to root, create the account and then exit. i have done the following:
#!/bin/ksh
## Script to create the mondba account ##
## Date 22Aug2007 ##
PATH=$PATH:/usr/local/bin:
export PATH
ssh -p 15560 user1@jupiter << EOW
su - root 2>&1
useradd -m -d /export/home/mondba -u 33332 mondba
passwd mondba
exit
EOW
exit

Now the problem, I will be prompted for the user1 password but not the root password which i'm supposed to get as a result of the su - i'm executing. Instead i get su: Sorry, looks like it gets timed out. Please give me a hint.
Thanks in advance!

Try this:

Put your script in a file, addmondba.sh, e.g. As the last (or second last) line of the script, put in "rm -f /tmp/addmondba.sh" to make the script delete itself. Then:

scp -p 15560 addmondba.sh user1@jupiter:/tmp
ssh -t -p 15560 user1@jupiter su root -c "\"sh -x /tmp/addmondba\""

If this doesn't work directly, it should get you closer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.