7

I'd like to have an SSH, HTTP and SMB server on standard ports on my phone.

There's a way to run Termux as root and have the servers run on privileged ports?

Running rooted Android 7.1 on an unlocked device.

10

The default su from Termux is simple. When run it brings /system/bin/sh for you instead of Termux's shell (typically bash). To solve this issue, you can install the custom su wrapper for Termux by

apt install tsu

And then you can run tsu so that your bash and everything is now under root privilege.

Further information:
Use an editor (like vim) to see /data/data/com.termux/files/usr/bin/su and you'll find that at line 10, it calls exec su $@ directly while in tsu, it performs shell detection and at line 80, it runs

exec su --preserve-environment -c "LD_LIBRARY_PATH=$PREFIX/lib $ROOT_SHELL"

to preserve the Termux enviroment.

3

I just solved the same problem for myself. tsu didn't work out for me. I found this project: https://github.com/st42/termux-sudo

Also I wanted to run sshd as root. It an out of the box with termux-sudo but it didn't want to use the authorized_keys file at first, because the permissions to it and all it's parent directories where not restricted to root (and on my device the / directory cannot be restricted to root 700, because then the mediaplayer software doesn't work anymore for some reason).

So I had to add the option StrictModes no to the sshd config file: /data/data/com.termux/files/usr/etc/ssh/sshd_config and now it works! :)

  • this helped, and should be the accepted answer – ArtDeineka Dec 25 '18 at 13:31
0

Once you run su it takes you out of the termux subshell. You can try SELinux permissive, that's how I get around the permission denied thing.

  • so like i type su, then superuser asks me for root permission, i give it, and then I have to run the servers as root? Or once i did that i can run servers with normal user but they still can get privileged ports? – Magnetic_dud Jan 20 '17 at 16:36

protected by Community Jan 24 at 8:20

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.