Visual Studio Code, commonly referred to as VS Code, is an integrated development environment developed by Microsoft for Windows, Linux, macOS and web browsers.
The VS Code Remote - SSH extension allows you to open a remote folder on any remote machine, virtual machine, or container with a running SSH server and take full advantage of VS Code's feature set. Once connected to a server, you can interact with files and folders anywhere on the remote filesystem. This extension allows you to work on files and folders on the Linux server directly from VS Code.
The Remote - SSH extension lets you use any remote machine with a SSH server as your development environment. This can greatly simplify development and troubleshooting in a wide variety of situations. You can:
Develop on the same operating system you deploy to or use larger, faster, or more specialized hardware than your local machine.
Quickly swap between different, remote development environments and safely make updates without worrying about impacting your local machine.
Access an existing development environment from multiple machines or locations.
Debug an application running somewhere else such as a customer site or in the cloud.
No source code needs to be on your local machine to gain these benefits since the extension runs commands and other extensions directly on the remote machine. You can open any folder on the remote machine and work with it just as you would if the folder were on your own machine.
You can connect to a running SSH server on the following platforms:
x86_64 Debian 8+, Ubuntu 16.04+, CentOS / RHEL 7+ Linux.
Windows 10 / Server 2016/2019 (1803+) using the official OpenSSH Server.
macOS 10.14+ (Mojave) SSH hosts with Remote Login enabled.
Visual Studio Code is pre-installed.
To connect to a Linux server via Visual Studio Code (VS Code), you can use the Remote - SSH extension. This extension allows you to work on files and folders on the Linux server directly from VS Code. Here’s a step-by-step guide:
1. Open VS Code.
2. Go to the Extensions view by clicking the Extensions icon in the Activity Bar on the side (or press Ctrl+Shift+X).
3. Search for Remote - SSH.
4. Click Install to add the extension to VS Code.
On Windows:
Open Command Prompt or PowerShell and run ssh to check if SSH is installed.
If not, install OpenSSH from Windows settings (Settings > Apps > Optional Features > Add a Feature > OpenSSH Client).
On macOS/Linux:
SSH is typically pre-installed. Confirm by running ssh in the terminal.
1. Select Remote-SSH: Connect to Host... from the Command Palette (F1, Ctrl+Shift+P)
2. Add hosting server
3. Connecting to the Server
4. Choose Config File (local) to Save SSH Information
5. Confirm to Connect
6. Input Server Password
7. Operate the Server
1. Once connected, a new window will open with the server's filesystem accessible in the Explorer pane.
2. You can open, edit, and save files directly on the server.
3. Use the integrated terminal to run commands on the remote server.
With this setup, you can seamlessly develop on your Linux server using VS Code!