This is the general version of: Send SIGTERM signal to a process running inside ssh
It is possible to send Ctrl-C to the remote process if the process gets a pty (-tt):
# Runs for 5 seconds
(sleep 5; echo '^C'; sleep 5) | time ssh -tt localhost burnP6
I had hoped the same would work for Ctrl-Z, but, alas, no:
# Continues to run - does not suspend
(sleep 5; echo '^Z'; sleep 5) | time ssh -tt localhost burnP6
If I get an interactive session, Ctrl-C and Ctrl-Z work fine.
Is there a way I can send other signals (I am especially interested in Ctrl-Z)?
I cannot use the suggested "ssh hostname 'kill -TERM $pid'" as I do not know the pids on the remote system.