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.
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.
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.
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! :)
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.