To solve your problem just use ssh -o TCPKeepAlive=no restOfYourCommandGoesHere
From the ssh_config manpage:
"TCPKeepAlive
Specifies whether the system should send TCP keepalive messages to the other side. If they are sent, death of
the connection or crash of one of the machines will be properly noticed. However, this means that connections
will die if the route is down temporarily, and some people find it annoying.
The default is ``yes'' (to send TCP keepalive messages), and the client will notice if the network goes down or
the remote host dies. This is important in scripts, and many users want it too.
To disable TCP keepalive messages, the value should be set to ``no''."
From the ssh_config manpage:
"TCPKeepAlive
Specifies whether the system should send TCP keepalive messages to the other side. If they are sent, death of the connection or crash of one of the machines will be properly noticed. However, this means that connections will die if the route is down temporarily, and some people find it annoying.
The default is ``yes'' (to send TCP keepalive messages), and the client will notice if the network goes down or the remote host dies. This is important in scripts, and many users want it too.
To disable TCP keepalive messages, the value should be set to ``no''."