How can I check that a remote computer is online for ssh / script access?
Like this:
nc -z hostname 22 > /dev/null
echo $?
If it's 0
then it's available. If it's 1
then it's not.
Use netcat:
nc -z localhost 22
From the manpage
-z Specifies that nc should just scan for listening daemons,
without sending any data to them.
What about
MACHINE=192.168.0.8
exec 3>/dev/tcp/${MACHINE}/22
if [ $? -eq 0 ]
then
echo "SSH up"
else
echo "SSH down"
fi