Terry Chen
Terry Chen

Reputation: 469

How does the local vscode client manipulate files in the remote machine?

With the remote-ssh extension, we can use vscode's remote development feature now, which means we can access the files in a remote machine from local vscode. And I found except the remote-ssh extension, there is a vscode-server working on remote machine to communicate with local vscode.

enter image description here

Looks like it's the bridge between local vscode and the file system in remote machine, which say vscode access remote files through the .vscode-server. But when I read vscode's source code, I still didn't find which protocol do they used to communicate, looks like it's not http, maybe it's ssh, but I still didn't get the details. Does any one know the details between local and remote on access remote file system? Such as how does the client initiate a file read, and how does the remote return the file content to the client, which protocol they use. And how remote executes command from local, such as the git commands in source control.

We can find some source code of the vscode-server in vscode:

https://github.com/microsoft/vscode/blob/main/src/server-main.js https://github.com/microsoft/vscode/tree/main/src/vs/server/node

Upvotes: 1

Views: 2335

Answers (1)

Bambam
Bambam

Reputation: 3899

not a complete answer but the extension that provides the remote connection is Microsoft/Github's "remote-ssh" (https://code.visualstudio.com/docs/remote/ssh). VS Code uses the ssh channel for effectively a peer-to-peer proprietary exchange between the local and remote machines after bootstrapping the process by using the ssh connection to issue commands to install their VS Code Server and its dependencies.

VS Code extensions generally have a link in their info to a Github repo containing the source but in the case of remote-ssh the repo is for feedback only & the code does not appear to be open source. (https://github.com/Microsoft/vscode-remote-release)

Note the remote-ssh extension is using remote code execution primarily to "take advantage of VS Code's full feature set" (presumably including remote build and debugging) rather than simple file access. That extension does provide remote file access, but there are far simpler extensions such as ftp-simple which provide only that.

Upvotes: 1

Related Questions