Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- scripted ssh login
- Florian Schoenbeck
July 28, 2007, 3:54 pm
rate this thread
I need to fetch some data from a Database which can be reached via a
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
That should work without problems because the login is without password. But how
can I shut
down the connection after the data is transfered?
Thanks a lot,
Re: scripted ssh login
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.
- » Strange issue while connecting using ssh / Need UDP ports open?
- — Next thread in » Secure Shell Forum
- » ssh on command line: force using a group size (prime size) of 1024 (and no...
- — Newest thread in » Secure Shell Forum