How to connect VSCode to a remote server using SSH
Jul 31, 2025 am 08:53 AM- Install the Remote - SSH extension from Microsoft in VSCode. 2. Click the green icon, choose "Connect to Host...", and enter an SSH command like ssh username@server-address -p PORT. 3. Save the configuration to the default SSH config file (~/.ssh/config). 4. Select the remote server’s OS (Linux/macOS/Windows) to allow VSCode to install the VS Code Server automatically. 5. Open a remote folder (e.g., /home/user/project) to start editing, running, and debugging code directly on the server, with all operations executed remotely, and use SSH keys or adjust SSH settings for improved connectivity and performance, ensuring the SSH port is open and stable for uninterrupted access.
Connecting VSCode to a remote server via SSH is straightforward using the Remote - SSH extension. This lets you edit, run, and debug code directly on a remote machine as if you were working locally. Here's how to set it up:

1. Install the Remote - SSH Extension
Open VSCode and go to the Extensions view (Ctrl Shift X
or Cmd Shift X
on macOS). Search for:
Remote - SSH
Install the official extension by Microsoft. It’s part of the "Remote Development" suite.

After installation, you’ll see a new green icon in the bottom-left corner of the status bar: "Open Remote Window".
2. Connect to Your Server
Click the green <> icon in the lower-left corner, then choose "Connect to Host..." → "Add New SSH Host...".

You’ll be prompted to enter an SSH command, like:
ssh username@server-address -p PORT
- Replace
username
with your remote user. - Replace
server-address
with the IP or domain. - Use
-p PORT
only if SSH runs on a non-default port (not 22).
For example:
ssh john@192.168.1.100 -p 2222
3. Choose SSH Config File
VSCode will ask where to save the SSH host configuration. Choose the default location (usually ~/.ssh/config
). This file manages your remote hosts.
After saving, VSCode will prompt you to "Connect" to the host. Click it.
The first time, you may need to confirm the server’s fingerprint and enter your password.
4. Select the Remote Server Platform
After authenticating, VSCode will ask what OS the remote server runs on:
- Linux
- macOS
- Windows
Choose the correct one. This affects how tools and paths are handled.
VSCode will then install the VS Code Server on the remote machine (in ~/.vscode-server/
). This is automatic and only happens once per server.
5. Open a Folder on the Remote Server
Once connected, VSCode opens a new window tied to the remote machine. Now click File > Open Folder and enter a path like:
/home/john/myproject
or
~/projects/app
You’re now working directly on the remote server. All edits, terminal commands, and extensions run remotely.
Tip: Open the integrated terminal (`Ctrl ``) — it runs on the server, not your local machine.
Tips & Troubleshooting
Use SSH keys for passwordless login:
Generate a key withssh-keygen
, then copy it usingssh-copy-id username@server
. This avoids typing passwords each time.Fix connection timeouts:
If the connection drops, edit your SSH config:Host your-server-name HostName 192.168.1.100 User john Port 2222 ServerAliveInterval 60 TCPKeepAlive yes
Firewall/Network Issues:
Make sure port 22 (or your custom SSH port) is open on the server.Slow performance?
Large file syncing or slow networks can affect responsiveness. Consider using Remote - SSH: Settings Sync or exclude large folders with.gitignore
or VSCode settings.
Once set up, switching between local and remote is easy — just use the green bottom-left icon to reconnect or disconnect.
Basically, it turns VSCode into a seamless bridge to your server — no more editing files over SFTP or running code locally that should run remotely.
The above is the detailed content of How to connect VSCode to a remote server using SSH. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The steps to build a Laravel environment on different operating systems are as follows: 1.Windows: Use XAMPP to install PHP and Composer, configure environment variables, and install Laravel. 2.Mac: Use Homebrew to install PHP and Composer and install Laravel. 3.Linux: Use Ubuntu to update the system, install PHP and Composer, and install Laravel. The specific commands and paths of each system are different, but the core steps are consistent to ensure the smooth construction of the Laravel development environment.

In VSCode, you can use Git for code version fallback. 1. Use gitreset--hardHEAD~1 to fall back to the previous version. 2. Use gitreset--hard to fall back to a specific commit. 3. Use gitrevert to safely fall back without changing history.

Configuring the Ruby development environment in VSCode requires the following steps: 1. Install Ruby: Download and install from the official website or using RubyInstaller. 2. Install the plug-in: Install CodeRunner and Ruby plug-ins in VSCode. 3. Set up the debugging environment: Install the DebuggerforRuby plug-in and create a launch.json file in the .vscode folder for configuration. This way, you can write, run, and debug Ruby code efficiently in VSCode.

The steps to manually install the plug-in package in VSCode are: 1. Download the .vsix file of the plug-in; 2. Open VSCode and press Ctrl Shift P (Windows/Linux) or Cmd Shift P (Mac) to call up the command panel; 3. Enter and select Extensions:InstallfromVSIX..., then select .vsix file and install. Manually installing plug-ins provides a flexible way to install, especially when the network is restricted or the plug-in market is unavailable, but attention needs to be paid to file security and possible dependencies.

Configuring VSCode to synchronize code with GitHub can improve development efficiency and team collaboration. First, install the "GitHubPullRequestsandIssues" and "GitLens" plugins; second, configure the GitHub account; then clone or create a repository; finally, submit and push the code to GitHub.

Best practices for writing JavaScript code in VSCode include: 1) Install Prettier, ESLint, and JavaScript (ES6) codesnippets extensions, 2) Configure launch.json files for debugging, and 3) Use modern JavaScript features and optimization loops to improve performance. With these settings and tricks, you can develop JavaScript code more efficiently in VSCode.

I have a lot of experience in participating in VSCode offline technology exchange activities, and my main gains include sharing of plug-in development, practical demonstrations and communication with other developers. 1. Sharing of plug-in development: I learned how to use VSCode's plug-in API to improve development efficiency, such as automatic formatting and static analysis plug-ins. 2. Practical demonstration: I learned how to use VSCode for remote development and realized its flexibility and scalability. 3. Communicate with developers: I have obtained skills to optimize VSCode startup speed, such as reducing the number of plug-ins loaded at startup and managing the plug-in loading order. In short, this event has benefited me a lot and I highly recommend those who are interested in VSCode to participate.

VSCode solves the problems of multilingual project coding and garbled code including: 1. Ensure that the file is saved with correct encoding and use the "redetection encoding" function; 2. Set the file encoding to UTF-8 and automatically detect the encoding; 3. Control whether to add BOM; 4. Use the "EncodingConverter" plug-in to convert encoding; 5. Use the multiple workspace functions to set encoding for different sub-projects; 6. Optimize performance and ignore unnecessary file monitoring. Through these steps, the coding problem of multilingual projects can be effectively dealt with.
