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.

3 Answers 3


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

  • this helped, and should be the accepted answer
    – ArtDeineka
    Commented Dec 25, 2018 at 13:31

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? Commented Jan 20, 2017 at 16:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .