6 min read Author: klaas

Remote development on a raspberry pi with ssh and VSCode

Remote development is a really cool and useful feature of VSCode. Especially handy if you want to develop on a raspberry pi on your local network. Although there are many ways to share code between two hosts, if you want a really direct way to interact this method is great. VScode has a remote development extension for this.

The extension connects with ssh to the remote host and establishes a tunneled connection. Since it uses ssh-keys to authenticate you don't need to enter passwords at all while still connected in a secure way.

The look and feel is the same as if you would develop locally. You can see in the image below that VScode is showing a remote folder in the titlebar of the window (saying [SSH: raspi4]) and in the bottom left of the statusbar stating: SSH: raspi4.


What you need to do:

On the raspberry

1) create a new development user on the remote raspi

Login as pi (or your admin  user on the raspi)

sudo useradd username

sudo usermod -aG sudo username

Switch to the new user


su -username

create a .ssh folder in /home/<name>

mkdir ~/.ssh

On your development system

2) Create a ssh key

ssh-keygen

(just enter everything. for local development don't use a passphrase otherwise you will have to enter the passphrase everytime. .. probably security overkill on your LAN)

  • You can find the new keypair (pub and private in /home/username/.ssh 
  • Show the id_rsa.pub with less

less /home/username/.ssh/id_rsa.pub

4) On the raspi open an editor (e.g. nano or vim) 

5) Copy & paste the .pub file content (you see with less) to the raspi authorized_keys

6) save the file  as: /home/username/.ssh/authorized_keys

Install the extension:

7) Install the remote development extension pack in VSCode on your development system.

8) Run Remote-SSH: Connect to Host... from the Command Palette (CTRL+SHift+P)

  • Connect as username@host

9) After you see that the connection is established just choose open file or open folder to open your development directory on the raspberry.

That's it.

For a more detailed description check these two articles.