6

I need to code / edit files in a remote server using SSH, and I would like to access it with VSCode.

I'm on Windows 10, using "Git Bash" as integrated terminal in VSCode, which means I can connect to the server using VSCode's terminal.
What I'm missing is a way to open files from the terminal to the editor, and even better - interacting with the files using the explorer.

How can this be done?

galah92
  • 3,621
  • 2
  • 29
  • 55

5 Answers5

7

Since the May, 2nd 2019 announcement of "Remote Development with VS Code", you now officially have:

Visual Studio Code Remote - SSH

https://microsoft.github.io/vscode-remote-release/images/ssh-readme.gif

The Remote - SSH extension lets you use any remote machine with a SSH server as your development environment.
Since nearly every desktop and server operating system has a SSH server that can be configured, the extension 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.

Q1 2020: VSCode 1.42 improves support for Windows servers, including automatic OS detection.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Is this safe? I mean, the plugin can push a private ssh key somewhere to the cloud in the background, how could we trust this? – swiss_knight Jul 01 '20 at 13:02
1

All of the previous answers require installing a package from the VS Code Marketplace. Here is a solution, that won't even require you to install VS Code.

The Web Based VS Code Editor: Run VS Code on any machine anywhere and access it in the browser.

All you need to do is, first install code-server using:

$ curl -fsSL https://code-server.dev/install.sh | sh

Start code-server using:

$ code-server

After running this you can log on to https://127.0.0.1:8080 and view the web-based VS code.

To keep the service running in the background, use:

$ sudo systemctl restart code-server@$USER

You might also want to edit the configurations, for e.g., run it on 0.0.0.0:8080 instead of 127.0.0.1:8080 or to change the password - use:

$ nano ~/.config/code-server/config.yaml

I have used nano as my text editor, feel free to use your preferred text editor.

For in-depth setup and configuration guide: Setup Guide

Original GitHub repo for more info: code-server

AverageGod
  • 95
  • 1
  • 6
0

Is this what you are looking for? https://marketplace.visualstudio.com/items?itemName=humy2833.ftp-simple#overview

You need to setup sFtp connection to your server.

Anwar Hossain
  • 654
  • 6
  • 21
0

Install extensions Code Runner and SSH-FS. Add config into your user setting like this:

"code-runner.runInTerminal":true,
"code-runner.fileDirectoryAsCwd": true,
"code-runner.ignoreSelection": true,
"code-runner.saveFileBeforeRun": true,
"files.eol": "\n",
"sshfs.configs": [
    {
        "label": "label",
        //Must use the root direction "/"
        "root": "/",
        "host": "host",
        "port": port,
        "username": "name",
        "password": "password"
        "name": "name"
    }]

Login your server account over ssh by the vscode terminal. Then you can edit and run your code on remote server.

RAM
  • 2,257
  • 2
  • 19
  • 41
0

Try disabling it and re-enabling it. It works for me.

I was able to log in via putty and ssh from terminal, so it wasn't that. It's just the configuration gets hung up or something.

Webmaster G
  • 502
  • 5
  • 12