How to make ssh to kill remote process when I interrupt ssh itself?
In a bash script I execute a command on a remote machine through ssh. If user breaks the script by pressing Ctrl+C it only stops the script - not even ssh client. Moreover even if I kill ssh client the remote command is still running...
How can make bash to kill local ssh client and remote command invocation on Crtl+c?
A simple script:
#/bin/bash ssh -n -x root@db-host 'mysqldump db' -r file.sql
Eventual I found a solution like that:
#/bin/bash ssh -t -x root@db-host 'mysqldump db' -r file.sql
So - I use '-t' instead of '-n'. Removing '-n', or using different user than root does not help.