Bash script to test if I can SSH to a server?
I have an environment when I lauch three virtual machines, then mount them via sshfs. I want to write a bash script to launch all three machines and mount them automatically.
My original plan was to use ping to identify when the servers were up, but they resolve via ping almost instantly. SSH login is only available later. The vast majority of the script is functioning, the only part I'm missing is a section to test if I can SSH into the machine yet or not. Psuedo-code: Code:
Loop |
Check if your netcat implementation supports the -z (list only, don't send data) option. If not, never mind. If so, you can use something like the following:
Code:
$ while true ; do nc -z 10.0.50.50 22 && break; echo 'Waiting for remote sshd...'; done |
Thanks, that worked perfectly!
|
All times are GMT -5. The time now is 02:08 PM. |