Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ssh script 1

Status
Not open for further replies.

bigmac13

Technical User
Sep 26, 2002
22
US
i need to run a shell script that does the following:

ssh to a machine on our local network and run 3 shutdown scripts. (and then another script that does the same thing but runs the startup script instead)

i've already got ssh set up with public/private keys and no pass phrase...

i've been able to get it to ssh and execute 1 command, but then it executes the other 2 commands on the local computer.
 
I don't have answer to your question right now..
May I see an example of this program..


Thanks,
Galger.
 
Ok I'm only testing from a localhost ssh with private/public keys (for its self) but it works like this for me:

ssh -v localhost "ls -al /tmp; who; ping -c 5 192.168.1.1"

The -v shows verbose so I can tell when it drops away from the ssh session .... and this first logs in with out password ... prints a ls of tmp ... then does a who .. then pings my router 5 times and then closes the ssh session and returns.

The " (quotes) holds the string of commands together and the ; (semicolon) splits them into a chain of commands to be run one after each other.

Otherwise why not lust place a script on the remote server that does the three commands and call that one script remotly from ssh?

Good Luck,
Laurie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top