VScode Remote Development using SSH on Embedded System RB Pi5

VScode Remote Development using SSH on Embedded System RB Pi5

Purpose:

Goal: Develop and edit Kubernetes code directly on a Raspberry Pi 5 using VS Code running on your PC. Why?

  • Headless Efficiency: You don't need to install a heavy GUI (Desktop Environment) on the Pi, saving RAM and CPU for your Kubernetes cluster.

  • Comfort: You get the full IntelliSense, debugging, and git integration of VS Code on your powerful desktop, while the code actually runs on the Pi.

Environment:

  1. Local Machine - A X86 Desktop (Ubuntu)
  2. Remote Host - Raspberry Pi 5. (Ubuntu)
  3. Working internet

Setting:

Step 1: Verify Connectivity

Before opening VS Code, ensure your PC can talk to the Pi via a standard terminal.

$ssh user@hostname_or_IP

If this works, you are ready to proceed.

Step 2: Install the Extension

  1. Open VS Code on your PC.
  2. Go to the Extensions view (Ctrl+Shift+X).
  3. Search for Remote - SSH and install it.


Step 3: Connect to Host

  1. Open the Command Palette (F1 or Ctrl+Shift+P).
  2. Type and select: Remote-SSH: Connect to Host...
  3. Enter your Pi's connection details: user@hostname_or_IP.
  4. Password: Enter your Pi's password when prompted at the top of the screen.

Step 4: Start Developing

  1. Once connected, you will see a green indicator in the bottom-left corner: >< SSH: hostname.
  2. Click Open Folder in the "Explorer" view.
  3. You will see the file system of the Raspberry Pi, not your local PC. Select your Kubernetes project folder.

Pro Tip: SSH Keys (Passwordless Login)

To avoid typing your password every time you reconnect or open a new folder, set up SSH keys.

  1. Generate a key on your PC:

    $ ssh-keygen -t ed25519
    # Press Enter for defaults
    
  2. Copy the key to the Pi:

    $ ssh-copy-id user@hostname_or_IP
  3. Now, VS Code will connect instantly without prompting for a password!

Reference:

System Requirements and more detail will be in the VS code web. 

Comments