Created
August 23, 2018 23:55
-
-
Save andymotta/cafb1e7618d603195a2e9b897c9902f6 to your computer and use it in GitHub Desktop.
Wait for ssh to come up in a Bash script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function hurryup () { | |
until ssh -o ConnectTimeout=2 "$1"@"$2" | |
do sleep 1 | |
done | |
} | |
hurryup root "10.10.0.3" | |
# -o ConnectTimeout=2 is a slightly hacky way of getting around not responding to network packets, | |
# reporting ssh: connect to host 10.10.0.3 port 22: Operation timed out until it's responsive. | |
# Then, when the host responding to network packets, the 1 second sleep with happen in-between | |
# ssh: connect to host 10.10.0.3 port 22: Connection refused as we wait for ssh to come up. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment