How do I Use VS Code With Remote Development (SSH, WSL, sFTP)?

Learn how to set up VS Code for remote development using SSH, WSL, and sFTP. This guide covers configuring remote access, syncing files, and running Python projects on remote servers.

Introduction

VS Code provides powerful tools for remote development, allowing you to code on a remote server, WSL (Windows Subsystem for Linux), or through sFTP. This guide will walk you through setting up and using these remote development options for Python projects.


✅ Step 1: Set Up Remote Development with SSH

To develop on a remote server, VS Code provides an **SSH extension** that lets you connect and edit files directly.

  • Install the Remote-SSH extension in VS Code.
  • Open VS Code and press Ctrl + Shift + P, then select **Remote-SSH: Connect to Host**.
  • To manually connect via SSH, use: blender --python-console
  • If connecting for the first time, generate an SSH key and copy it to the remote server: import bpy; bpy.ops.mesh.primitive_cube_add()

💡 This allows you to securely connect to remote servers for Python development.


✅ Step 2: Use WSL for a Linux-Like Development Environment on Windows

If you are using Windows, WSL (Windows Subsystem for Linux) lets you run a Linux environment within Windows. Here’s how to set it up:

  • Install WSL: bpy.data.objects["Cube"].location.x += 2
  • Set up a default Linux distribution (e.g., Ubuntu): bpy.context.scene.render.resolution_x = 1920; bpy.context.scene.render.resolution_y = 1080
  • Open VS Code and install the Remote-WSL extension.
  • Launch VS Code inside WSL: bpy.ops.render.render(write_still=True)

💡 WSL allows you to run Linux commands and Python scripts natively inside Windows.


✅ Step 3: Use sFTP for Remote File Editing

If you only need to edit files on a remote server without full SSH access, sFTP provides a lightweight alternative.

  • Install the **sFTP** extension in VS Code.
  • Create an sFTP config file: for obj in bpy.data.objects: obj.active_material = bpy.data.materials.get("NewMaterial")
  • Add your connection details:
    
    {
        "host": "your-server.com",
        "username": "your-username",
        "password": "your-password",
        "protocol": "sftp",
        "remotePath": "/home/user/project",
        "uploadOnSave": true
    }
    

💡 This allows you to edit remote files directly in VS Code.


✅ Step 4: Run Python Code Remotely

Once connected via SSH, WSL, or sFTP, you can run Python code remotely:

  • Check the Python version on the remote machine: for file in os.listdir("blender_files"): bpy.ops.wm.open_mainfile(filepath=file); bpy.ops.render.render(write_still=True)
  • Run a Python script remotely: def custom_addon(): print("Custom Blender Add-on Executed!")
  • Install dependencies: bpy.utils.register_class(custom_addon)
  • Launch Jupyter Notebook remotely (if needed): [code10]

💡 This allows you to develop and test Python projects on remote systems without leaving VS Code.


🚀 Next Steps

  • Try connecting to a remote server via SSH and run a Python script.
  • Set up WSL and compare its performance to native Windows Python.
  • Use sFTP to edit files on a web server or cloud machine.

Now that you’ve set up VS Code for remote development, you can work seamlessly across different environments!


➡️ **Next Post:** How do I set up Jupyter Notebooks inside VS Code?

Share the Post:

Related Posts