vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

code tunnel to local machine directly

Open zyzhang1992 opened this issue 2 years ago • 19 comments

We use code tunnel on a HPC cluster. Our cluster uses 2 factor authorization and doesn't allow tunnel connection to azure machines, as currently implemented for code tunnel.

We request a new feature that allows tunnel and authenticate to the local vscode client from the code tunnel running on a compute node on a remote cluster. The tunnel connects the local machine to the compute node on the remote cluster via the log in nodes on the remote cluster.

This will open up the possibility of running code tunnel/vscode server in any desirable environment on a HPC cluster. This will enable development work in HPC environments that are not possible otherwise.

zyzhang1992 avatar Apr 15 '23 02:04 zyzhang1992

We use code tunnel on a HPC cluster. Our cluster uses 2 factor authorization and doesn't allow tunnel connection to azure machines, as currently implemented for code tunnel.

We request a new feature that allows tunnel and authenticate to the local vscode client from the code tunnel running on a compute node on a remote cluster. The tunnel connects the local machine to the compute node on the remote cluster via the log in nodes on the remote cluster.

This will open up the possibility of running code tunnel/vscode server in any desirable environment on a HPC cluster. This will enable development work in HPC environments that are not possible otherwise.

almutlaq88 avatar Apr 15 '23 18:04 almutlaq88

We use code tunnel on a HPC cluster. Our cluster uses 2 factor authorization and doesn't allow tunnel connection to azure machines, as currently implemented for code tunnel.

We request a new feature that allows tunnel and authenticate to the local vscode client from the code tunnel running on a compute node on a remote cluster. The tunnel connects the local machine to the compute node on the remote cluster via the log in nodes on the remote cluster.

This will open up the possibility of running code tunnel/vscode server in any desirable environment on a HPC cluster. This will enable development work in HPC environments that are not possible otherwise.

almutlaq88 avatar Apr 15 '23 18:04 almutlaq88

@eleanorjboyd any thoughts on this?

zyzhang1992 avatar Apr 18 '23 02:04 zyzhang1992

@roblourens and @connor4312 I think one of you would be able to answer this- thanks!

eleanorjboyd avatar Apr 18 '23 16:04 eleanorjboyd

I think peer to peer connections may already be on @derekbekoe's backlog for tunnels 🙂

connor4312 avatar Apr 18 '23 23:04 connor4312

If I understand this request correctly, it would also be amazing for development on Android - running code tunnel in Termux and accessing from vscode.dev on the same phone/tablet, through localhost instead having to go through a remote web server :)

jonaskuske avatar Apr 22 '23 17:04 jonaskuske

@eleanorjboyd @connor4312 @derekbekoe any updates on this? let me know if there is anything that we can be of help with

zyzhang1992 avatar Aug 04 '23 16:08 zyzhang1992

We are not currently looking into peer to peer connections; it hasn't been a common ask. However, it'd be great to understand the scenario more for consideration for the future.

I'd like to better understand why Remote - SSH doesn't meet your needs here? A network diagram that illustrates the use-case may help (e.g. current state and proposed state). Thanks.

derekbekoe avatar Aug 04 '23 17:08 derekbekoe

(example of how to do this with remote ssh https://code.visualstudio.com/blogs/2019/10/03/remote-ssh-tips-and-tricks#_proxycommand)

connor4312 avatar Aug 04 '23 17:08 connor4312

"Thanks, Derek @derekbekoe and Connor @connor4312. We do use the remote ssh/server feature of VSCode. However, there are some limitations due to how VSCode is currently designed for use as a remote development tool on an HPC cluster. VSCode starts the remote server in the environment specified in the .bashrc, and there's no way to change that environment once the server starts. This means the development environment is limited to that alone. However, it's often necessary to modify the development environment, for example, by adding or removing software modules. It's also not uncommon for a developer to work in several different development environments simultaneously. I've found that the code tunnel mechanism works perfectly for these situations. I can start a terminal on a remote machine, define a specific software environment in that shell, and then the code tunnel will start the code server, inheriting that specific software environment of that shell for development purposes in the VSCode server. I can start different servers via the tunnel mechanism, each with its own specific development environment. Interestingly and usefully, I can use this setup to create a development/debugging environment for Singularity containers on an HPC cluster.

The only problem, which may not necessarily be a problem for some, is that the tunnel currently goes through a GitHub server. This allows connections to the tunnel endpoint on GitHub, and thus to the remote HPC cluster, without SSH and/or 2FA authentication. This may not be what system admins want to see happening.

A tunnel directly to the user's client machine should eliminate that concern. That might already be possible, as I've noticed there are options for tunnels directly to the remote servers on the local VSCode platform. I'm not sure if that's the case, and if so, how to set it up. Perhaps it wouldn't be too much effort to support a tunnel to the local client machine that could be authenticated with SSH/2FA, instead of through a GitHub endpoint. That could be a significant benefit for developers in the HPC community."

zyzhang1992 avatar Aug 05 '23 04:08 zyzhang1992

vscode.dev do not support SSH remote and we need to connect to remote server in browser(iPad).

wweir avatar Aug 07 '23 12:08 wweir

Seems like these two existing issues in relation to "Remote - SSH" would address the key points raised so that "SSH" could be used instead of "Tunnels"?:

  • @zyzhang1992 - https://github.com/microsoft/vscode-remote-release/issues/1722
  • @wweir - https://github.com/microsoft/vscode-remote-release/issues/5750

The tunneling service supporting peer-to-peer connections doesn't appear a prerequisite to addressing the linked issues.

derekbekoe avatar Aug 09 '23 05:08 derekbekoe

Thanks @derekbekoe

Seems like these two existing issues in relation to "Remote - SSH" would address the key points raised so that "SSH" could be used instead of "Tunnels"?:

Yes and no. The 1st issue https://github.com/microsoft/vscode-remote-release/issues/1722 does discuss similar features that are desirable for typical HPC environment on a cluster but the solutions leave much to be desired.

The discussion here, https://github.com/microsoft/vscode-remote-release/issues/1722#issuecomment-1302548127, could be a working solution using the Remote Command feature of ssh config. Looks like it is possible to start the vscode server on a compute node, and also within an shell environment that user can specify in the server_start.sh, other than that specified with bashrc. However it is a messy procedure that (1) could be error prone and (2) difficult for most users (even the more sophisticated) to follow.

The other potential problem with this solution/procedure is that the RemoteComand option of ssh config may or may not work, depending on the local ssh version and the local OS (Windows, Mac, or Linux)

The other solution provided, https://github.com/microsoft/vscode-remote-release/issues/1722#issuecomment-1483162486, indeed is the most elegant and very much consistent with the workflow on a cluster. This is indeed what the current issue is for. This solution fits perfectly with the configuration of shell environment and allocation of resources with a resource manager like slurm. The issue with this approach is the tunnel and its authetification through an intermediate host, other than the local host and the remote host that users are in total control c.f. https://github.com/microsoft/vscode-remote-release/issues/8373#issuecomment-1666387857 and https://github.com/microsoft/vscode-remote-release/issues/1722#issuecomment-1557793249 for the discussion related to PHI/HIPAA.

Again, if the tunnel is a ssh tunnel, secured with ssh and 2FA, between the local host and the vscode server running on the remote host, it will be compliant with PHI/HIPAA. Perhaps this may be the solution? https://github.com/microsoft/vscode/issues/168492#issue-1485118445

This is an interesting feature but doesn't seem to directly address the issues discussed here.

The tunneling service supporting peer-to-peer connections doesn't appear a prerequisite to addressing the linked issues.

zyzhang1992 avatar Aug 13 '23 15:08 zyzhang1992

I have the same need for this issue. Our company uses the slurm (software that assigns the GPU to each user) as the management platform. The problem is the assigned terminal is not allowed to link with SSH so that we couldn't use the feature in Remote-SSH. We find the code tunnel could effectively address such a problem, however, the latency is much higher than expected. We hope that there are some local method to relieve it.

Suchun-sv avatar Aug 17 '23 08:08 Suchun-sv

We have similar problems to what @zyzhang1992 describes.

On our HPC environment we have some restrictions on connecting via third party servers without our own authentication methods due to data protection laws.

Additionally, as @zyzhang1992 mentioned, the solutions in the linked issues are error prone, create unnecessary overhead and not applicable for many users.

A good solution would be a VScode server instance running on the cluster, which then gets connected to a local editor instance via port forwarding. The benefit would be that in HPC environments, the user gets more control on the configuration of the compute node in comparison to the remoteSSH approach.

The main reason for this is that the configuration of proxy jumps and environments is less flexible in handling the "random" allocation of a compute node and in configuring the needed resources, leading to a lot overhead just to connect to a compute node.

With remote tunnels, it would be possible to start an interactive job, specify the needed resources, wait for the node to be allocated, set up the environment and then start the remove server, where it is supposed to run. Then it is just a matter of port forwarding and connecting to the tunnel.

As an example, a similar approach is widely used with Jupyter Notebooks/Jupyter Lab, which is great for explorative data analysis, but lacks many of the SE features provided by VScode.

Finally, with the recent implementation of starting VScode server on a local port in [code server] Bring over serve-local option from code-server preview to new code tunnel command #168492 , the solution to connect to a "self hosted tunnel" as requested in #7527 should be halfway done.

sroener avatar Aug 30 '23 12:08 sroener

I'd like this feature as well

lattice0 avatar Oct 04 '23 04:10 lattice0

Any news on this Issue?

@connor4312 @derekbekoe

Is there a plan to implement something like a self hosted tunnel that a VScode editor is able to connect to? I imagine something like a listener service, which can be forwarded via ssh to which the editor front-end is able to connect. From my understanding, the jupyter functionality in VScode does something similar. Would this be possible, or is there something in the tunnels implementation that complicates the forwarding/connection part?

Additionally, the previous mentioned issue https://github.com/microsoft/vscode-remote-release/issues/1722 is a collection of hacky solutions to circumvent the immediate starting of the vscode backend after logging into a login-node of a cluster. These solutions are error prone and usually very specific for the respective cluster environment.

If there is anything that can be done apart from writing the actual code, let me know.

sroener avatar Nov 03 '23 10:11 sroener

Has there been any updates regarding this?

kl13nt-tng avatar Aug 19 '24 08:08 kl13nt-tng

Any progress on this one?

ShreyasJejurkar avatar Aug 22 '24 12:08 ShreyasJejurkar

bump... Any progress on this one?

rb-synth avatar Sep 03 '24 14:09 rb-synth

Bump. I have a shotty internet connection and I want to target a machine on my local network. Uless I'm in the wrong place.

codenamezjames avatar Oct 21 '24 02:10 codenamezjames

Bump. I have a shotty internet connection and I want to target a machine on my local network. Uless I'm in the wrong place.

@codenamezjames an option would be to self host your vscode with code serve-web, and forward a port to it

lattice0 avatar Oct 21 '24 02:10 lattice0

This will do it: a complete replacement for code-server with Copilot support. Thanks @lattice0!

calebrunion avatar Nov 16 '24 19:11 calebrunion

I would like to have this, but we're still waiting on the upstream feature. I will reopen this issue if/when we get that.

Folks who want this might also want to check out code serve-web which runs a VS Code server via HTTP on the machine.

connor4312 avatar Dec 11 '24 20:12 connor4312

bump - this is the only way to run devcontainers inside a VM that also runs on my host. I have no desire to install docker on the host, just in the VMs.

m1tk4 avatar Jan 21 '25 18:01 m1tk4

I often use code on a train - where the internet signal is intermittent (UK, they have terrible WiFi, and the cellular signal isn't good outside of the cities.). If I could spin up a host either on android, or on a raspberry pi zero or similar and connect to that without relying on a cloud service, then I could continue to work given signal interruptions.

lukew151 avatar Feb 19 '25 21:02 lukew151

One big difference with SSH and Tunnel is that you have to have an SSH server running on the remote machine. In my experience, clicking the "install tunnels as a service" is far easier to set up than an SSH server (depending on the machine; linux is not too bad of course but still requires looking up the commands each time and such).

Also of course installing an SSH server can be more risky security wise, and on work computers can be much more difficult (I recently switched to windows/PowerShell from using WSL for like 10 years) permission wise. But VSCode tunnels are more isolated and of course don't open an incoming port, so has many benefits in that regard.

The code server might work nicely but not sure the interface will be quite as nice as tunnels is; it would be awesome to be able to run a tunnel on the client machine that the server could connect to (all traffic would be outgoing from the remote server), but any configuration would be nice that has all the configurability in VSCode directly, bypassing the need to install an SSH Server on the remote.

Seems like there are benefits to the remote machine being only a client could have benefits, for connecting to microcontrollers, non-admin machines, etc., since running a server typically is more intensive than connecting.

Anyway just wanted to give my experience. Remove development with VSCode is super awesome already, enhancements would be even more. Thanks

s-jacob-powell avatar Jul 24 '25 15:07 s-jacob-powell