Using your server comfortably with VS Code (Remote-SSH)
With VS Code's Remote-SSH extension, you don't need to upload and download code back and forth: you can open and edit files on the server directly, and even use its terminal, just as if you were working in a local editor. Highly recommended if you use a Linux (SSH) server.
1. Install the extension
- Open VS Code.
- Click the Extensions icon in the left sidebar.
- Search for Remote - SSH and install it. (By Microsoft,
ms-vscode-remote.remote-ssh)
2. Add your server
- Open the Command Palette with
F1orCtrl+Shift+P(Cmd+Shift+Pon macOS). - Select Remote-SSH: Add New SSH Host.
- Enter it in the format below. (Replace
usernameandip-addresswith the connection info from your Dashboard)
ssh username@ip-address
- When asked where to save the SSH config file, choose the default (
~/.ssh/configin your user home directory).
3. Connect
- Open the Command Palette again and select Remote-SSH: Connect to Host.
- Click the server you just added.
- A new window opens and tries to connect to the server. Enter your password.
- Once connected, the server info appears at the bottom left. Open the directory you want with "Open Folder", and you can now edit files on the server directly, just like local files.
- Open a terminal with
Ctrl+`and you're connected straight to the server's terminal.
If typing your password every time is a hassle
Set up "Connecting without a password using SSH keys" from the SSH connection guide first, and VS Code will also connect right away without a password.
Tips
- If you add several servers, you can quickly switch between them in the Remote Explorer in the left sidebar.
- Extensions you install while connected through Remote-SSH (Python, ESLint, etc.) are installed separately on the server side and don't affect your local environment.
- If the connection is slow, try adding the following options to
~/.ssh/config.
Host *
ServerAliveInterval 60
Compression yes