Re: scripted ssh login
- From: Darren Tucker <dtucker@xxxxxxxxxxxxxxxx>
- Date: Sun, 29 Jul 2007 13:14:43 +1000
On 2007-07-28, Florian Schoenbeck <schoenbeck@xxxxxxxxxx> wrote:
I need to fetch some data from a Database which can be reached via
a ssh-tunneled TCP-port. Manually, everything works fine. First,
the ssh-connection is established and after that, the data is fetched.
Now I need to run this as a cron job, so I need to establish the
ssh-connection by script. That should work without problems because
the login is without password. But how can I shut down the connection
after the data is transfered?
What I used to do was run something like "sleep 5" with ssh -f and the
tunnel. If the sleep exits before the tunnel closes, the remote sshd
will wait for the tunnel to close before closing the ssh connection, so
the sleep just needs to be long enough to establish the tunneled
connection. This should work for most software and versions.
Another alternative, if you're using a recent OpenSSH, is to use the
ControlMaster option when establishing the connection, then use "ssh -O
exit" option to shut the master down when your script is done.
--
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
.
- References:
- scripted ssh login
- From: Florian Schoenbeck
- scripted ssh login
- Prev by Date: Re: scripted ssh login
- Previous by thread: Re: scripted ssh login
- Index(es):
Relevant Pages
|
|