If you have a OpenSSH server running on the client you can configure it to force a certain command to be run for a particular key. If done correctly this key can only be used to trigger this notification and not for any significantly nefarious stuff.
To make things less confusing (because in this case we have both sides action either client or server) I will call the local machine, i.e. the client you connect to the remote server to start the long-lasting task on, Alice. Bob will then the server where to start the compile task on which is then supposed to notify Alice about the completion of the task.
For this you would have you basically just generate a key using
ssh-keygen -f notif_key and then add the public key (
notif_key.pub) to a separate line in your Alice's
.ssh/authorized_keys but prepended with:
command="/path/to/notifier.sh \"$SSH_ORIGINAL_COMMAND\"",no-port-forwarding,no-x11-forwarding,no-agent-forwarding ssh-rsa …
ssh-rsa … stands for the public key.)
notifier.sh is a script on Alice's side then which then calls the notification command (of course you can start right away if possible, just note that the whole line is executed in a shell).
On Bob's side you can then trigger the notification on Alice's side using
ssh, so all in all you run on Bob inside the
time-consuming-command; ssh -i notif_key user@alice_pc foobar
And that's it!
$SSH_ORIGINAL_COMMAND is a placeholder for all the extra command line for the
ssh command which then gets forwarded to the forced command. This way you could customize the particular notification from Bob, e.g. for when you run multiple tasks this way at once at once.
notifier.sh with that in mind:
some-notification-command --message "Task '$*' is done!"
echo 'Note to Bob: Alice has been notified.'
All in all, this solution is far from optimal. It requires an OpenSSH server on the client and is quite some hassle to configure. I hope better solutions exist.