I've changed my household router and broadband recently (to BT Infinity), and I've noticed that my SSH server has become fairly unreliable. Of course, I've set SSH to be forwarded to the correct host on the new router, and this must be true as I can sometimes connect to it remotely, but sometimes not.
I have a dedi and was hoping to make a script that would occasionally 'ping' the SSH server every now and then, to test if it was up. Is there a way to invoke the SSH command so that it just handshakes with the server and does no more, and returns a helpful status code to say the server is up or down? Just so that I can add it to a script like this:
#!/bin/bash LOG_FILE="$HOME/ssh.log" while [ true ]; do testSSH if [ $? -ne 0 ]; then echo "`date +%y%m%d-%H%M%S` server down" >> $LOG_FILE fi sleep 60 done
or, alternatively, would it be easy to make such a program?
EDIT: as an aside, if anyone's interested or is in the know on this, I've changed my port forwarding settings to user-defined IP address instead of by MAC address (the default), just incase, with the SSH host having a static IP. Not that I use MAC spoofing at all, but just because I've heard it's 'buggy' on the home hub. When I look at the connected devices page, I don't see my computer on there. There are switches between my computer and the router, but that shouldn't make any difference, right?