ssh to termux server disconnects after X seconds I upgraded termux recently. 

When I do:

ssh phone


it disconnects after 44 seconds. It disconnects even if there is activity in the session (eg. ping google.com).

If I am active in termux using the phone, then ssh does not disconnect. So it seems Android is killing the ssh connection. tcpdump confirms that and shows a reset packet is sent from the phone killing the connection:

13:30:37.093254 IP 192.168.1.122.2222 &gt; 192.168.1.129.41938: Flags [R.], seq 4542, ack 5622, win 396, options [nop,nop,TS val 3374991 ecr 3768615485], length 0


Before upgrading termux this did not happen. So something happened during the upgrade that caused this to happen.

I have tried both to click acquire wakelock and release wakelock. Neither helped.

I have tried both to click allow and don't allow in Battery Optimization for Termux. Neither helped.

As a workaround I can connect USB. Then Android does not disconnect the ssh-connection. This makes me think the disconnection is deliberate and related to power saving.

How can I make Android not kill the ssh connection?
Thanks to @IrfanLatif I looked at battery options again.

And my phone was in Power Saving mode. When I disabled that, everything worked - whether Termux is running in the foreground or not.

So the problem was not related to the upgrade of Termux.