Install code-server on Android

Student
Search for a command to run...

Student
No comments yet. Be the first to comment.
If you've ever faced the challenge of running graphical user interface (GUI) programs within a container, fear not! While it may seem like a daunting task at first, with this comprehensive guide, we'll walk through the process using Incus Container. ...

When working with containers, managing file sharing between the host system and container can often pose a challenge. However, there is an easy-to-use solution that simplifies this process using just one line of code! This blog post will guide you on...

Incus, a manager and hypervisor for system containers (LXC) and virtual machines (QEMU), is an excellent tool for managing and orchestrating your applications and services. It is a fork of LXD by the original maintainers. I found the documentation re...

Using ble.sh and Starship. Bash by itself is pretty basic. Syntax highlighting, auto-suggestion and history matching are pretty helpful features in any shell. Users might be worried about the bloat these features bring and add delay to the startup of...

The ability to run virtual machines (VMs) and docker containers is an integral part of today’s modern computing landscape. However, issues with internet connectivity inside these environments often cause significant inconvenience for users who depend...

If you are here then I assume you already know the purpose of using code-server. So why on phone? Phones these days have become quite powerful. Maybe you have an older laptop lying around. The existence of code-server on Android implies there is at least one use case being fulfilled. So I will not pursue the topic any further.
Get it from F-Droid.
Termux is a terminal emulator that allows you to use the command line tools you are familiar with. Root is not needed for our purpose. You can ssh into it or use a bluetooth keyboard if you are not a fan of typing on small screens.
You can use the automated script provided by Coder or follow a manual approach as explained below.
In Termux, run apt update && apt upgrade. Now we need a few packages to get started. Install them with apt install build-essential python git nodejs yarn. Install code-server by running yarn global add code-server.
Installing code-server will take a while. It took around 20 minutes on my phone (Snapdragon 665). B
Start code-server by entering code-server in Termux.
By default, it will listen on localhost which is of little help on a small screen. We want to use it on a larger screen like a notebook. There are two ways to achieve this: a) change bind address, and b) use port forwarding.
Change bind-addr to 0.0.0.0:8080 in ~/.config/code-server/config.yaml.
Now go to your browser (preferably connected to the same network) and enter your phone's IP address with port (which is 8080 in this case). It will ask for a password. Use the one in the config file.
Install openssh by running apt install openssh. Set your password by running passwd. Check username with whoami. You may also set up a key pair if you like. In that case, change the config accordingly.
Now start the SSH server by running sshd. On remote machine, run the following in your console
ssh -N -f -L 8080:<your phone's IP address>:8080 <termux username>@<phone's IP address>
If you are using key pair, tell ssh to use the key
ssh -i /path/to/your/key -N -f -L 8080:<your phone's IP address>:8080 <termux username>@<phone's IP address>
Open a browser and go to localhost:8080.
Stop code-server, update the above packages, remove code-server (it will not remove config files and stuff) and install code-server. Which means running
apt update && apt upgrade
yarn global remove code-server
yarn global add code-server
