Remote-SSH Extension for VS Code
The Remote-SSH extension in VS Code enables you to work on remote projects as if they were on your local machine. With Remote-SSH, you can connect to a remote server, edit files, run commands, and use VS Code’s development features.
Installing the Remote-SSH Extension
-
Open VS Code.
-
Go to the Extensions panel (Ctrl+Shift+X on Windows/Linux or Cmd+Shift+X on macOS).
-
Search for Remote - SSH and click Install.
Connecting to a Remote Machine
After installing the extension, follow these steps to connect to a remote server via SSH:
-
Press F1 or Ctrl+Shift+P to open the Command Palette.
-
Type
Remote-SSH: Connect to Host
and select it. -
Enter the SSH connection details, e.g.,
user@remote-server.com
. -
Select your preferred remote OS when prompted (Linux, macOS, or Windows).
Once connected, a new VS Code window will open, and you’ll be working within the remote environment.
Using the SSH Config File in VS Code
If you have an SSH config file (located at ~/.ssh/config
), VS Code will automatically detect the hostnames you’ve configured.
-
Press
F1
and type "Remote-SSH: Connect to Host." -
You should see the hostnames from your SSH config file listed. Select the appropriate one to connect.
Remote-SSH Features
When connected via Remote-SSH, you can:
-
Open and edit files directly on the remote server.
-
Use VS Code’s terminal to run commands on the remote machine.
-
Install extensions specific to the remote environment.
VS Code handles the heavy lifting of syncing your local environment to the remote, making it a seamless experience.
Installing Extensions on the Remote Machine
Some extensions are required to be installed on the remote machine itself. When you attempt to use such an extension, VS Code will prompt you to install the remote version of the extension automatically.
For example, if you try to use the Python extension on a remote server, VS Code will prompt you to install the extension remotely.
# Example of opening a Python file remotely, which triggers extension installation.
code myscript.py
On Linux you may need to add the Alternatively, you can add the following line to your
Or you can create an alias in your
|