Multiple ssh, shutdown and exit script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Multiple ssh, shutdown and exit script
# 1  
Old 06-30-2009
Multiple ssh, shutdown and exit script

PROBLEM:

I need to ssh into multiple remote machines, send a shutdown command and exit. The remote servers will then run their own scripts to gracefully shutdown their applications before shutting down.

ONE: This is to be achieved without using public key authentication; this is being avoided as a security measure. (Not negotiable) :-)

TWO: Passwords are required.

SO FAR:
I wrote an expect script that ssh's into the remote server, and calls on a script. Trouble is the expect script on the "master" server waits for the remote script to complete before exiting,thus time is wasted (I am trying to shut down several servers within a certain time).

Is there a way to run multiple instances of my expect script simultaneously, or /and is there another way to do this. If sequentially, then in the shortest time possible.


Thanks!!!
# 2  
Old 07-02-2009
Well the only UNIX box I can think of which was able of parallele cmds was IBM SP (big blue...and followers).
I tried rdist and fell on your situation, and that was due to the loop...
Havent tried with rsync though... and havent tried multiple instance of expect, but did try at the time a workaround to speed up things:
schedule cron for the presence of a dummy file ( I did this for Y2K testings for shutdown of 30 servers.. )to execute your shutdown script.

---------- Post updated at 09:53 ---------- Previous update was at 09:48 ----------

Thinking of it now, you could try to schedule with at in your expect, that would be faster since after the at cmd (something like at now + 2 minutes...) it would have finished (if it works..) keep us informed (could be interesting!)
# 3  
Old 07-02-2009
Quote:
ONE: This is to be achieved without using public key authentication; this is being avoided as a security measure. (Not negotiable) :-)
Then may I suggest that your supervisors invest in this technology

Seriously, create a listening daemon each server that responds only to a specific IP address, and if really necessary, a password string. Once the string has been received, issue the shutdown command. It's a 5 line perl program. No need to parallelize since the string is sent and your client script just goes to the next server.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ssh script to validate ssh connection to multiple serves with status

Hi, I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not... I have .sh script like below and i have servers.txt contains all the list of servers #/bin/bash for host in $(cat... (3 Replies)
Discussion started by: sreeram4
3 Replies

2. Shell Programming and Scripting

While loop is causing ssh command to exit from script after first iteration.

I am trying to check multiple server's "uptime" in a loop over "ssh". When I execute multiple ssh commands with hard coded servernames script is executing fine. But when I pass server names using while loop, script is exiting after checking first server's status, why? # serverList... (8 Replies)
Discussion started by: kchinnam
8 Replies

3. Shell Programming and Scripting

Exit script when shutdown or reboot command is given

This is probably a simple question, but I'm new with writing scripts for Linux (IPFire in this case) and Google wasn't helpful with this. When creating a script, what is the best and/or proper way to have it exit automatically if the reboot or shutdown command is given? If that's even... (2 Replies)
Discussion started by: bartgrefte
2 Replies

4. Shell Programming and Scripting

Shell script to connect to multiple ssh servers

Hello, I have access to several linux servers (mostly centos based) located in a DC in another country. from day to day I need to login to each of them to do some work (they dont have gui/window manager installed, I work only from console), or even to just do a check like df -h for disc usage.... (3 Replies)
Discussion started by: MaRiOsGR
3 Replies

5. Shell Programming and Scripting

How to test for the ssh exit status in script?

Hello; I regularly run monitoring scripts over ssh to monitoring scripts But whenever a server is hung or in maintenance mode, my script hangs.. Are there anyways to trap exit status and be on my way ?? Looked at the ssh manpage and all I can see is a "-q" option for quiet mode .. Thank... (2 Replies)
Discussion started by: delphys
2 Replies

6. Shell Programming and Scripting

expect ssh script cannot finish and exit

All i am new to linux, and try to have a simple expect script to ssh then telnet to the network equipment, and exit itself. but dont know why i hang at the last $ #!/usr/bin/expect set timeout 10 set arg set arg1 spawn ssh -l UserA 1.1.1.1 expect "assword:"; send "PasSwOrD\r";... (1 Reply)
Discussion started by: samoptimus
1 Replies

7. UNIX for Dummies Questions & Answers

Script to force Oracle database shutdown when shutdown immediate does not work

I have Oracle 9i R2 on AIX 5.2. My Database is running in shared server mode (MTS). Sometimes when I shutdown the database it shutsdown cleanly in 4-5 mints and sometimes it takes good 15-20 minutes and then I get some ora-600 errors and only way to shutdown is by opening another session and... (7 Replies)
Discussion started by: aixhp
7 Replies

8. Shell Programming and Scripting

I need a Script to rsh multiple hp boxes and shutdown

Hello I'm serving on a ship that has frequent power issues. Currently if we loose power we need to rush around to multiple UNIX machines and login to Sysadmin and power down each machine before we loose our ups. If sysadmin is asleep or not in the space we have some real problems. I would like to... (2 Replies)
Discussion started by: blackfam972
2 Replies

9. UNIX for Advanced & Expert Users

How to exit ssh

Hi, I have a script that runs ssh to multiple systems. It does the folowing : ssh -f -T server1 "/sbin/init.d/logsurfer newstart" Running it using the -f option at least the prompt gets back, running it without the -f the prompt does not even show up. You have to press <Ctrl> + c to get the... (1 Reply)
Discussion started by: davidg
1 Replies
Login or Register to Ask a Question