2020-11-05 update VSCode has already support
aarch64
, no more needVSCode Insiders
Original intention
Since VSCode added the remote ssh, it can separate interface and backend, and only need ssh protocol to connect backend, Recently, I had the idea that I could create an ssh port on my Android phone, and then use VSCode to run a server on my phone, When you go out, you can write and read code by connecting to Android, after all, the performance of the smartphone is good enough.
My phone is a OnePlus 7 Pro official system, not rooted.
Android sshd prepare - Termux
Termux is a lightweight, cross-platform, open source, cross-platform terminal emulator. I have introduced it in DevOps pains and the use of Termux, the termux could also start an OpenSSH server in the phone:
1 | $ pkg install openssh-server |
Use telnet
to check the server.
After that, we need to create a ssh key-pair, or use the exist public key.
You could use adb push
to push the publish key to the phone, and then copy it to the authorized_keys.
1 | $ termux-setup-storage |
Then, you may connect the phone throught the terminal:
1 | ~ ❤ ssh [email protected] -p 8022 -i ~/.ssh/id_rsa_raspberry |
There is part of the ssh_config:
1 | Host oneplus |
First connection in VSCode
There is a problem aarch64 is only supported in VS Code Insiders
So, I use VSCode Insiders https://code.visualstudio.com/insiders/.
First connection in VSCode Insiders
There is another error that node can’t run:
I’m trying to use node
to run js code, but I still got errors.
This time I guessed that the Android runtime library was missing some files, and I didn’t give up, and turned to look for containers on Android.
Containers in Android
I found a tool that can run containers in Android: https://github.com/nmilosev/anyfed.
It uses proot
, which means you don’t need root your Android phone.
You can notice it get a Fedora image.
- Setup the cpu arch
- Donwload the container
- Configure sudo and proot
- Try to start the container
You need:
1 | $ unset LD_PRELOAD |
There is no ssh
in the anyfed, so we need to install openssh-server
:
1 | [root@anyfed home]$ sshd |
You need to create another
ssh_config
, and this time we use root user:
1 | Host oneplus2 |
1 | ~ ❤ ssh oneplus2 |
Second connection in VSCode Insiders
It works!
I clone a repo in GitHub, use VSCode open it.
A notict to install Python extensions
Compare to the old laptop, the smartphone performance is better.
Conclution
VSCode actually give us a solution to use the idle resource in smartphone to develop. As the smartphone is more powerful, the performance is also better. I’m no doubt that one day the performance of the smartphone is good enough to allow us to develop on it. I’d like to combine VSCode and Frp as a solution to develop on Android smartphone.