I am in the process of creating a bash script that would log into the remote machines and create private and public keys.
My problem is that the remote machines are not very reliable, and they are not always up. I need a bash script that would check if the SSH connection is up. Before actually creating the keys for future use.
You can use something like this
This will output "ok" if ssh connection is ok
If you would like to check a remote folder exists, or any other file-test really:
Do not forget the quotes in
"$(ssh ...)"
.Example Using BASH 4+ script:
https://onpyth.blogspot.com/2019/08/check-ping-connectivity-to-multiple-host.html
Above link is to create Python script for checking connectivity. You can use similar method and use:
Command to create bash script.
To connect to a server with multiple interfaces