If you want to send keep alive messages across an ssh connection, check the documentation for your ssh implementation,
for me reveals a KeepAlive directive which will have ssh send keep alive messages over the connection so you don't have to worry about it timing out. If you have the TMOUT variable set, it could be bash which is disconnecting you and not your ssh connection.