To test my program on a remote host I run command:ssh address ./my_executable. The my_executable is a long running program but during development I often interrupt it using CTRL+C. The issue is that CTRL+C interrupts ssh session without killing my process so when I try to run it again I have an error because my process still use resources.

Currently I'm using a workaround: ssh address ./my_executable; echo DONE; ssh address pkill my_executable

But is there a better way to interrupt a program executed through ssh in command mode?

The problem doesn't occur of course when I log in with ssh address and run the executable then because signals are passed to remote terminal but it requires more typing and it can't be automated. 

1 Answer 1


If you tell ssh to explicitly use a terminal, even though it doesn’t need one, you’ll get the behaviour you want:

ssh -t address ./my_executable

Then CtrlC will kill my_executable, not ssh (which will exit immediately anyway, because the connection is closed when my_executable exits).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .