termux-app icon indicating copy to clipboard operation
termux-app copied to clipboard

[Bug]: sshd no longer works

Open ballo opened this issue 9 months ago • 11 comments

Problem description

This is on the latest F-Droid Termux on Android 15 on a POS Pixel 7.

I used to be able to set the phone to hotspot mode then ssh to the phone via port 8022. For reasons unknown this is now failing every so often. It fails for a long period of time then seems to clear up and allows me to use it again. The port is open according to nmap, and I can still use the phone via scrcpy (adb on port 5555), but when I attempt an ssh it prompts me for a password then fails to provide a shell nor can it pipe sockets via -L or -D. I have tried killing and restarting sshd as well as force quitting Termux to no avail. I'm pretty familiar with all things UNIX and this one has me stumped, so I'm guessing it's something specific to Termux or Android which has put me in this bind.

Steps to reproduce the behavior.

Unfortunately these kinds of problems are difficult to reproduce, but it is happening. I'm not doing anything fancy with Termux. I do have the termus-api app installed so I can monitor the battery level.

What is the expected behavior?

I should be able to ssh to my phone at all times. The phone is still responsive in that I can use adb/scrcpy so it hasn't crashed nor hardly used any memory

System information

  • Termux application version: 0.118.1
  • Android OS version: 15
  • Device model: POS Pixel 7

ballo avatar Mar 27 '25 19:03 ballo

Try to capture logs with logcat when it happens and post the logs here, I hope it will make a situation a bit more clear.

twaik avatar Mar 27 '25 19:03 twaik

What would I be logging?

ballo avatar Mar 28 '25 03:03 ballo

logcat.

twaik avatar Mar 28 '25 09:03 twaik

Could be related to Termux app being frozen by Android.

  • https://github.com/termux/termux-packages/blob/site/site/pages/en/projects/docs/repos/main/packages/termux-tools/logcat/index.md#to-get-full-system-logs-of-other-apps-and-the-android-system
  • https://github.com/termux/termux-api/issues/638#issuecomment-1813233924

agnostic-apollo avatar Mar 28 '25 10:03 agnostic-apollo

Could be related to Termux app being frozen by Android.

I don't know if this is relevant but I could use termux via scrcpy while this was happening.

ballo avatar Mar 28 '25 17:03 ballo

Then probably not related, could be network optimizations with screen off

agnostic-apollo avatar Mar 28 '25 20:03 agnostic-apollo

I have it sometimes as well (Termux 118.1, Android 14), but it is mostly due to screen off. Turning on the screen fixes it. Always disable full battery optimizations for the Termux app. In rare cases I had to kick (reboot) my phone and it was fixed. And are you sure sshd daemon is loaded ? nmap -v -Pn localhost should show open port 8022. Let it be clear: in most cases I can ssh into my phone using either ssh in a terminal or a GUI sftp client (on Linux and macOS, I don't have Windows).

freebrowser1 avatar Mar 30 '25 00:03 freebrowser1

You still did not send logcat logs after running sshd.

twaik avatar Apr 26 '25 10:04 twaik

My somewhat crappy work-around is to use scrcpy to gain access to the termux app, killall sshd, then run it again.

ballo avatar May 03 '25 16:05 ballo

Have you tried starting it as sshd -D on the command line (to prevent it from daemonizing), and seeing (a) what it prints to STDOUT/STDERR and (b) if having it as a process with an open window fixes the issue? Also, that way you can kill it easily using a simple CTRL-C. And you'll see if the process lives (and how long -- a prompt containing the time helps with that) or if it exists immediately.

Flexximilian avatar May 17 '25 17:05 Flexximilian

Port 8022 is already binded, sshd fails, worked fine before updating, was updated through ssh, I'd love to post the logcat but ssh doesn't work so not feasable since I'm miles away from my phone to copy paste it manually on pastebin. Again this used to work fine just before updating.

UleyeyeUwma avatar Jun 17 '25 21:06 UleyeyeUwma