Created
February 10, 2019 09:28
-
-
Save kocoten1992/42eb2cb3497907b7587b0eecc020a29a to your computer and use it in GitHub Desktop.
check we could establish ssh connection using bash
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 | |
# source http://mindspill.net/computing/linux-notes/bash-script-to-check-ssh-connection/ | |
ssh -q -o BatchMode=yes -o ConnectTimeout=10 example.com exit | |
if [ $? -ne 0 ] | |
then | |
# Do stuff here if example.com SSH is down | |
echo 'Can not connect to example.com' | mail -s "example.com down" whoever@wherever | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment