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.
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.Sign up to join this community
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.
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.
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! :)