Turning Your Old Raspberry Pi into an Ad Blocker: Say Goodbye to Online Ads

Resources Center


Explore variety of our blogs, and expand your knowledge!

Coding on Raspberry Pi remotely with Visual Studio Code

Do you always find it hard to program and code on your Raspberry Pi? every time you need to connect it to a display, keyboard, and mouse every time?  Well, here’s the solution! After this guide, you can use only your PC for everything. Just power up your Raspberry Pi, and let your PC handle it. We’ll be using something called SSH to make this happen. But what’s SSH?

1- SSH

SSH or Secure Shell is a network communication protocol that enables two computers to communicate. And for our luck, 
Raspberry Pi OS has a built-in future which allows us to enable SSH with simple steps.

2- Enable SSH in Raspberry Pi

First of all, we need to open “Terminal” if we are using “Raspberry Pi OS with desktop” or just start typing the commands if we are using “Raspberry Pi OS Lite”
Enter   sudo raspi-config  This command will show you all the available options. Now with the arrows select Interfacing Options, navigate to and select SSH, choose Yes, and select Ok.

3- Enable SSH in Raspberry Pi 

First of all, we need to open “Terminal” if we are using “Raspberry Pi OS with desktop” or just start typing the commands if we are using “Raspberry Pi OS Lite”
Enter   sudo raspi-config  This command will show you all the available options. Now with the arrows select Interfacing Options, navigate to and select SSH, choose Yes, and select Ok.

Now we have to set our Visual Studio code.

4- Install the Extensions on VS Code

Visual Studio Code offers a lot of extensions, and to install any extension we have to click on the extensions button and then search for “Remote – SSH” and it will show up, click install to install it. 

5- Add Raspberry Pi IP to SSH

Once you’ve successfully installed the extension, you’ll notice a new section dedicated to it. Go to this section and select the small ‘+’ button to incorporate a new host 

6- Enter the SSH credentials

You will be prompted to provide the SSH connection command. If your Raspberry Pi is running the Raspberry Pi OS, the username is typically ‘pi’. Also, you can type “raspberrypi” instead of your IP. Once you have input the connection command, as illustrated below, press Enter.

7-  Select the configuration file

SSH keys need to be stored on your local file system, and VS Code will inquire about your preference for their location. I opted for the .ssh folder under my user directory, as depicted in the image.

You will see a notification that says ‘Host added!’

8- Establish a connection with your Raspberry Pi.

You should be able to see your Raspberry Pi as listed under the ‘SSH’ on the left side. Click on the small folder icon to connect to your host.

You’ll be prompted for the password; enter it and then press ‘Enter’.

VS Code will ask you to select the OS of your Raspberry Pi, which is Linux, and then it will inform you that it is installing ‘VS Code Server’ on the Raspberry Pi, which is necessary for synchronization between the development environment and its file system.

 

9- Navigate through your folders 

Click ‘Open Folder’ to show all your folders, then choose one to start coding in

Great job! You’ve successfully learned how to remotely code on a Raspberry Pi using VS Code on your computer with the Remote – SSH extension.

10-Conclusion

Time is precious in software development, whether it’s a professional pursuit or a hobby. The repetitive task of synchronizing files between systems can significantly impact your productivity. This guide will assist you in establishing an efficient and productive workflow.