How to Use Visual Studio Code to Explore and Edit Files on a Remote Server via SSH Tunnel

In today’s interconnected world, remote work and server management have become increasingly common. Whether you’re a developer, sysadmin, or just someone who needs to access files on a remote server, having the right tools at your disposal can make all the difference. Visual Studio Code (VSCode), a popular code editor, offers a powerful extension that allows you to seamlessly explore and edit files on a remote server via an SSH tunnel. In this guide, we’ll walk you through the steps to set up and use this feature effectively.


Before we dive into the process, make sure you have the following prerequisites:

  1. Visual Studio Code: If you haven’t already, download and install Visual Studio Code.

  2. Remote Server: You should have access to a remote server via SSH. Ensure that you have the server’s IP address or hostname, SSH username, and password or SSH key.

Step 1: Install the “Remote - SSH” Extension

To enable remote development in VSCode, you’ll need to install the “Remote - SSH” extension. Follow these steps:

  1. Open VSCode.

  2. Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window.

  3. In the search bar, type “Remote - SSH” and press Enter.

  4. Click the “Install” button next to the “Remote - SSH” extension by Microsoft.

Install Remote - SSH Extension

  1. After installation, click the “Reload” button to activate the extension.

Step 2: Configure SSH Settings

Now that you have the extension installed, you need to configure SSH settings for your remote server:

  1. Press Ctrl+Shift+P (or Cmd+Shift+P on macOS) to open the command palette.

  2. Type “Remote-SSH: Connect to Host” and select it from the list.

  3. Click on “Add New SSH Host” at the bottom of the list.

  4. Enter the SSH connection details for your remote server:

    • Name: A memorable name for your server configuration.
    • Hostname: The IP address or hostname of your remote server.
    • Port: The SSH port (usually 22).
    • User: Your SSH username.
    • Identity File: If you use SSH key authentication, provide the path to your private key file.

Configure SSH Settings

  1. Click “Add” to save the configuration.

Step 3: Connect to the Remote Server

With your server configuration set up, connecting to the remote server is straightforward:

  1. Press Ctrl+Shift+P (or Cmd+Shift+P on macOS) to open the command palette.

  2. Type “Remote-SSH: Connect to Host” and select your server configuration from the list.

  3. VSCode will establish an SSH connection to your remote server. You might be prompted to enter your SSH password or passphrase if you didn’t use an SSH key.

  4. Once connected, you’ll see a new VSCode window with the remote server’s name in the bottom-left corner.

Step 4: Explore and Edit Files

Now that you’re connected to your remote server, you can explore and edit files just as you would on your local machine:

  1. Open the file explorer by clicking on the file icon in the Activity Bar on the side.

  2. You’ll see your remote server’s file system, and you can navigate and open files and folders.

  3. To edit a file, simply double-click it, and it will open in the VSCode editor.

  4. Make your changes, save the file, and VSCode will automatically sync it back to the remote server.

Explore and Edit Files

Step 5: Disconnect from the Remote Server

When you’re done working on the remote server, you can easily disconnect:

  1. Click on the green “Remote - SSH” status bar in the bottom-left corner of the VSCode window.

  2. Select “Disconnect from Host.”

  3. VSCode will close the remote connection, and you’ll be back in your local environment.

Common Uses

The ability to explore and edit files on a remote server via SSH tunnel using Visual Studio Code opens up a world of possibilities for developers and system administrators. Here are some common use cases where this feature comes in handy:

1. Editing Nginx Configuration Files: - Previously, many administrators and developers relied on text editors like Vim or Nano to make changes to Nginx configuration files. With VSCode’s remote editing capabilities, you can seamlessly modify your Nginx configurations on the remote server, enhancing your productivity and reducing the learning curve associated with traditional terminal-based editors.

2. Web Development on Remote Servers: - If you host your web applications on remote servers, you can now directly edit your HTML, CSS, JavaScript, and other web files using VSCode. This streamlines the development process, allowing you to preview changes and maintain version control effortlessly.

3. Collaborative Coding: - Collaborating with team members on a remote project is simplified with VSCode’s remote capabilities. You can share access to the same server, making it easy to work together on codebases, troubleshoot issues, and provide real-time support.

4. Server Configuration Management: - Managing server configurations often involves editing various files scattered across the file system. VSCode’s remote editing feature centralizes this process, making it more efficient and organized. Whether you’re adjusting firewall rules, configuring system services, or tweaking system files, VSCode simplifies the task.

5. Debugging and Troubleshooting: - Debugging remote applications or troubleshooting server-related issues becomes more accessible with VSCode’s remote debugging support. You can set breakpoints, inspect variables, and step through code just as if you were working locally.

6. Data Analysis on Remote Datasets: - Data scientists and analysts can leverage VSCode’s capabilities to explore and analyze datasets residing on remote servers. This eliminates the need to transfer large datasets to a local machine, saving time and resources.

7. Rapid Prototyping: - When working on prototypes or proof-of-concept projects hosted remotely, using VSCode allows for quick iteration. You can make changes, test them immediately, and iterate rapidly without the need for frequent file transfers.

8. Remote Scripting and Automation: - Automating tasks on remote servers is made more accessible with VSCode’s integrated terminal and scripting support. You can create and run scripts directly on the server, making routine maintenance and administrative tasks more efficient.

9. Cloud Development: - When working with cloud-based servers or containers, VSCode’s remote features enable you to connect and edit files within your cloud environment easily. This is particularly useful for cloud-native development and DevOps tasks.

10. Cross-Platform Development: - VSCode is available on multiple platforms, allowing developers to work on remote servers regardless of their operating system. This flexibility is invaluable when collaborating with colleagues or clients using different environments.

In essence, Visual Studio Code’s remote development capabilities extend beyond just editing files; they transform the way you interact with remote servers, enhancing productivity, collaboration, and efficiency in various domains of software development and server management. Whether you’re a seasoned developer, a system administrator, or a data analyst, integrating this feature into your workflow can significantly improve your remote work experience.


Visual Studio Code’s “Remote - SSH” extension simplifies the process of exploring and editing files on remote servers via SSH tunneling. With a few simple configurations, you can seamlessly integrate your remote development workflow into your favorite code editor. This feature is invaluable for developers, system administrators, and anyone who needs to manage remote servers efficiently. Give it a try and see how it can streamline your remote work processes. Happy coding!