wait for autossh connection to complete
listed in answer
ANSWER:
If I understand you correctly your problem is that you want to wait until authentication succeeds before continuing with the rest of your script.
I would solve this with public key authentication and ssh-agent.
Once this is configured and ssh-agent is running, ssh won’t ask for a password and your script will authenticate correctly each time. (It’s not quite the same as ensuring the connection is working but it may suffice for your purposes)
Two other workarounds come to mind:
- Use tcptraceroute in a while loop to check that a port forward is working (assuming you have port forwards in use or can create one for this purpose). Don’t break out of the loop until you get a successful reply.
- Place your long-running commands in a script on the remote side, and execute those in screen or nohup. One trick I’ve used in the past is to generate a script, then copy it to the remote side, then execute it using nohup.

New Comments