Create /etc/pm/sleep.d/05_ssh_keepawake file
$ sudo vim /etc/pm/sleep.d/05_ssh_keepawake
Copy the following content to the file
#check for SSH sessions, and prevent suspending:
if [ `who | grep -cv "(:"` -gt 0 ]; then
echo "SSH session(s) are on. Not suspending."
Make it executable
$ sudo chmod +x /etc/pm/sleep.d/05_ssh_keepawake
Make sure to reboot your system to take effect!