TechCraft

VSCode on iPad Pro - Full Setup Guide with Raspberry Pi

Full setup guide for installing code-server on your Raspberry Pi.

Installing NodeJS

Updated August 1st, 2022:

Code Server requires NodeJS 16. The easiest way to get NodeJS 16 on your Pi is to install the binary packages from NodeSource:

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs

If you'd rather not pipe a random shell script into bash, then you can find the manual instructions for this here.

Installing code-server

With NodeJS installed, you can now install code-server:

First install Yarn:

sudo npm -g install yarn

Then, using yarn install code-server:

yarn global add code-server

Test the Installation

Start code-server by running

~/.yarn/bin/code-server

You should see something like this:

[2022-03-04T20:37:35.946Z] info  Wrote default config file to ~/.config/code-server/config.yaml
[2022-03-04T20:37:37.202Z] info code-server 4.1.0-4946-9e620e90f53fb91338a2ba1aaa2e556d42ae52d5 9e620e90f53fb91338a2ba1aaa2e556d42ae52d5
[2022-03-04T20:37:37.206Z] info Using user-data-dir ~/.local/share/code-server
[2022-03-04T20:37:37.253Z] info Using config file ~/.config/code-server/config.yaml
[2022-03-04T20:37:37.253Z] info HTTP server listening on http://127.0.0.1:8080/
[2022-03-04T20:37:37.253Z] info - Authentication is enabled
[2022-03-04T20:37:37.254Z] info - Using password from ~/.config/code-server/config.yaml
[2022-03-04T20:37:37.254Z] info - Not serving HTTPS

Configuring code-server

By default, code-server is only accessible from the machine it is installed on. To fix that, we'll edit the bind-addr property in the config file at ~/.config/code-server/config.yaml

bind-addr: 0.0.0.0:8080
auth: password
password: mypassword
cert: false

Feel free to set the password to your liking.

Start code-server automatically

As the superuser (sudo vim or sudo nano will do the job), create this file at /etc/systemd/system/code-server.service

[Unit]
Description=code-server
After=network.target

[Service]
User=pi
Group=pi

WorkingDirectory=/home/pi
Environment="PATH=/usr/bin"
ExecStart=/home/pi/.yarn/bin/code-server

[Install]
WantedBy=multi-user.target

Then run sudo systemctl enable code-server to tell your Pi to start the code-server automatically. Now is a good time to reboot and check that auto start actually works!

Configuring the iPad Home Screen Icon

Firstly, stop code-server:

sudo systemctl stop code-server

Then temporarily disable authentication for code-server by setting auth to none in ~/.config/code-server/config.yaml:

bind-addr: 0.0.0.0:8080
auth: none
password: mypassword
cert: false

This allows Safari to load the Code Server icons correctly.

Now, in safari, visit the URL of your code-server. My Pi has hostname codepi so the address in Safari is http://codepi.local:8080.

Safari Address Bar

From here, hit the share button in the top corner and select Add To Home.

Add to Home Screen

Enabling Secure Mode

First get the hostname for your Pi with the hostname command.

hostname

Next edit ~/.config/code-server/config.yaml, set cert to true and set cert-host to your hostname with .local appended:

bind-addr: 0.0.0.0:8080
auth: none
password: mypassword
cert: true
cert-host: codepi.local

Restart code-server:

sudo systemctl restart code-server

This creates a certificate in ~/.local/share/code-server. The name of the certificate corresponds to your hostname, mine is codepi_local.crt.

This file needs to be copied to the iPad and installed. If you're a Blink user you can do this with the file mount shown in the video. To install see here in the video.