User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,450 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,613 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 3639 | Replies: 1
Reply
Join Date: Aug 2007
Posts: 1
Reputation: earlysame55 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
earlysame55 earlysame55 is offline Offline
Newbie Poster

ssh shell script

  #1  
Aug 23rd, 2007
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!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Posts: 57
Reputation: Fest3er is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 2
Fest3er Fest3er is offline Offline
Junior Poster in Training

Re: ssh shell script

  #2  
Aug 23rd, 2007
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.
Last edited by Fest3er : Aug 23rd, 2007 at 11:25 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:57 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC