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

running multiple commands via ssh quickly



I have various shell scripts that do something like the following:

if ssh -a -x remote-machine remote-command > local-file
then
  ssh -a -x remote-machine another-command
  local-command
else
  ssh -a -x remote-machine third-command
  another-local-command
fi

and more complicated variations.  The commands in question are
very fast, but the script is slow because ssh needs to authenticate
each time.  (I run ssh-agent and have entered an identity into the
agent before running the script, so no passwords need to be typed.)

What I am looking for is a way to just authenticate once, and then
have the ability to run remote commands getting the error code and
the output on the local machine.

Is there an easy way to do this?

The sort of thing I imagine is running ssh once to forward a local
port to the remote machine, and then somehow sending commands along
the channel and getting the error code and output also on that
channel.  But this seems a bit tricky to set up.

Thanks for any ideas.

Dan

-- 
Dan Christensen
jdc@math.jhu.edu


Reply to: