Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use VS Code Remote with offline client #1242

Open
roblourens opened this issue Aug 24, 2019 · 29 comments
Open

Use VS Code Remote with offline client #1242

roblourens opened this issue Aug 24, 2019 · 29 comments
Labels
feature-request Request for new features or functionality plan-review PM-highlighted item determined to be P1 or P2 ssh Issue in vscode-remote SSH

Comments

@roblourens
Copy link
Member

#15 improved the experience when connecting to a host that isn't connected to the internet. Some users also need to connect from a client that is not connected to the internet. This would require a way for them to manually download the server and set it up on the host, or give it to the client to transfer to each host. And the user would have to do this after every vscode update.

@Chuxel
Copy link
Member

Chuxel commented Aug 27, 2019

Hmmm the number of permutations here could get pretty large over time. We now have:

  • x86_64 glibc Linux
  • AArch32 glibc Linux
  • AArch64 glibc Linux

Planned:

  • x86_64 Windows
  • x86_64 macOS
  • x86_64 musl Linux (e.g. Alpine - supported in Containers, WSL, ultimately SSH)

There's a number of others that have been requested ranging from MIPS and Power PC to alternate operating systems like BSD. I'm sure musl/Alpine for ARM will come up. Clearly we would need a solid Node implication to step into any of these along with community test support, but it illustrates a general class of problem that the dynamic story solves.

I guess we'd likely need a page with all the different permutations people can grab.

@WSLUser
Copy link

WSLUser commented Sep 3, 2019

1.) As mentioned in #15, settings should be provided to choose the server to download (in the Settings UI as well as obviously settings.json). Whenever VSCode updates, the server would be updated as well.

2.) Users should probably be able to choose to download more than one server. Then when client connects to the host, the extension does a check to see which server it should use. Discovering this, it then transfers the server over to the host and does the install.

3.) Extensions should be downloaded for use by the server at the same time as the server downloads based once again upon the architecture.

For now, we just need 1 done followed by 3. 2 is an eventual need for some users but probably not as much of a need as 1 and 3.

@ttutko
Copy link

ttutko commented Sep 5, 2019

I mentioned this in #15 but I would like to mention it here too. The C++ extension from Microsoft seems to handle this well by providing the offline installers for the components that get downloaded (https://github.com/microsoft/vscode-cpptools).

Granted remote plugin is slightly trickier in that it really needs to exist on two machines but I would think that we could use a similar mechanism to download whichever permutations we want/need to our local machines (or a network share) and then use a setting to specify the location from which to pull the server files. The setting could default to empty or to some other value to indicate that it should be downloaded from github as it does now but if it's set to a path (local or network share), then it should look for the needed server in that location. I think it would be reasonable for the plugin to do a quick (short timeout) check for internet to see if there are any newer versions of the server and produce a warning message that newer versions are available but should still use the version of the server from whatever location is specified.

@david-dumke
Copy link

david-dumke commented Sep 10, 2019

Why wouldn't we just cache whatever we determine at runtime after an update and use the cached copy until the next update. Most users will have connectivity at some point, its really just about getting this working at home or on the go when I may not have internet 24/7. The configuration is also quite static. I will only be using it on a specific machine with a specific setup, sure there are lots of permutations but VSCode is already doing the work of figuring out which files to download, it sounds like a simple change to cache that and use the cached copies if no updates are needed. Additionally if it couldn't connect to the internet it would skip updating the files and just run as is.

@WSLUser
Copy link

WSLUser commented Sep 10, 2019

getting this working at home or on the go

There are corporate and government networks as well that may be more lenient with the client OS but not the remote server. I have such a case for my use-case. Nobody developing at home should need to worry about it if it's personal network. That should simply be a matter of updating FW rules to allow traffic from the endpoints they specify in the docs.

@BMellor
Copy link

BMellor commented Sep 10, 2019

@strike5150: Don't be so sure about "most" users having connectivity at some point. Many corporations don't allow internet access except via a protected browser. Other applications are firewalled and can only access the internal network. Those that use VSCode at my work have to manually download update and extension files.

@yangxiang92
Copy link

Agree with @BMellor . A lot of corporations do not allow internet access because of information security concern.
For me, I install all the required components on a computer with internet access and copy all the files related to vscode to another offline machine with the same enviroment as the previous one to make vscode-server possible to run on a offline machine.
However, with current version of vscode-remote-ssh extention, it checks internet connection when the vscode-server is already installed. It makes my trick not working any more. I think this is not reasonable.

@roblourens
Copy link
Member Author

However, with current version of vscode-remote-ssh extention, it checks internet connection when the vscode-server is already installed

Can you open a new issue and explain some more, and include the log from the Remote-SSH output channel?

@yangxiang92
Copy link

yangxiang92 commented Sep 19, 2019

I think i might have solved the problem. Thank you for your attention. @roblourens

I reviewed the javascript code of the vscode-remote-ssh. It seems that the plugin is trying to use wget on the target machine to get something from the localhost, which is the target machine, to check if the server is working. But mine plugin seems to always get a invalid output from the wget command.

I double checked my vscode configuration on two machine (offline and online), and found that the offline machine has a vscode-remote-ssh plugin at version 0.45.2. However, the online machine, which is the one works fine, had a vscode-remote-ssh plugin at version 0.46.1. I upgraded the plugin of the offline machine to 0.46.1 and all problems were solved. The issue should be caused by the mis-match version of plugin and server, though the root-cause is not clear yet.

@xiekeyi98
Copy link

I think we should have two settings:

  1. Local host and remote host neither have internet.
  2. Only remote host have not internet.( Because remote host is like IDC or Cloud ).

As 2 , Can we use local host as a proxy to install remote-ssh( And I think this can be default).
Indeed, I'am puzzled why we need remote host to access Internet? I think we can do everything by local host.

And another suggest:
I found it will use "SSH TCP FORWARD" , but in out company, "SSH FORWARD" without approval is irregular, and we not use 22 as SSH port. Is there anyway to avoid ssh forward?

@roblourens
Copy link
Member Author

2 is already supported, like the OP says. You can set "remote.SSH.allowLocalServerDownload": true.

@WSLUser
Copy link

WSLUser commented Sep 20, 2019

A quick fix for now that should be enabled anyways: Fix this error: Version mismatch, client refused.

How is this error generated? Assuming someone manually grabbed the tar.gz manually, then installed it on the remote host:

Update the extension,
Attempt to connect, it will fail.
Copy the contents of the previous server installed to the new commit id directory in .vscode-server-insiders/bin. Close ssh remote window and restart window. Watch it bypass the install as it detects an installation but fail to connect.

This error can been seen when looking at extensions. The actual output says something about curl failing. Seeing how the client refused to connect due to a hard-coded line for the version, this makes sense. The server should at least allow the last 5 versions to work before providing a prompt in a Windows Dialog preferably to install a new version with a link to the servers provided for quick easy one click download, which we could click on when disconnected from the corporate network.

At that point we could then save it to wherever the server temporarily lives on client side, tell the extension to look for it when attempting to connect once the secure connection between client and host is in place. Discovering it, it will then proceed with the scp and installation process.

@IgnusG
Copy link

IgnusG commented Nov 20, 2019

Is this the same as #1242?

#1802 (comment)

@WSLUser
Copy link

WSLUser commented Nov 20, 2019

I would consider it a sub task. Though I actually tested the recent Nightly and it appears that whenever you update VSCode, the issue I mentioned above (and also #1802 (comment) ) occurs. Updating the extension itself no longer seems to be the problem, perhaps it never was. So more accurately, VS Code should keep compatibility with the previous 5 servers. I think it's a check in the extension that verifies the server version is the same as what's reported by VSCode (Insiders) and so fails if they mismatch. IMO the only reason the server shouldn't work is because it becomes too incompatible with the VSCode client. Connecting itself should never be the problem.

@Coderx7
Copy link

Coderx7 commented Jan 27, 2020

Its been around 2~3 months since the last comment here, Is there any update in this regard? should we or can we be expecting something in near future(even possibly the next release) to address this ?

@fakhamatia
Copy link

I use this trick for both side offline connection.
But when VSCode release an update commit id its change and I must download files again and upload on servers and extract tar.
I use VPNs to connect servers and when use VPN my internet disconnect, VSCode cant download new files.
Luckily extension install and update on servers without internet and complete offline connection.

@PavelSosin-320
Copy link

@fakhamatia Some WiFi routers running OpenWRT Unix has SSH Server package installed. Check your model in OpenWRT portal

@Spriithy
Copy link

Have there been any advancements towards using Remote SSH when neither hosts are connected to internet ? Thanks

@JP01
Copy link

JP01 commented Jul 8, 2021

Have there been any updates on this? Is it on the roadmap?
Thanks

@cleep55
Copy link

cleep55 commented Sep 6, 2021

Where can I find older versions? I have an older version of vscode 1.52.1 on an offline network. I can't update vscode but would like to add the extension... I think it is 0.64.0_1 that I need...

@awesomebytes
Copy link

Just wanted to support this issue. I have been bitten by it multiple times already. I want to thank anyone that may be looking into it.

@skaravos
Copy link

skaravos commented Sep 2, 2022

+1
It has been over 3 years since this issue was opened, has there been any progress at all?

@aleksanm
Copy link

+1 It has been over 3 years since this issue was opened, has there been any progress at all?

One way to get it done:
https://linuxtut.com/en/af61a2593f4ed1d4085c/

@max-sixty
Copy link

max-sixty commented Sep 14, 2022

If anyone needs to do this — here's an approach that worked for me for the past couple of years:

  • Download the server in an online system with wget -q https://update.code.visualstudio.com/${VSCODE_VERSION}/server-linux-x64/stable -O - | tar -xz; the version should be like 1.67.1. The client & server versions need to match exactly.
  • Put the extension in the correct place in the offline system. Here's a Taskfile definition for doing this; would be easy to turn into a bash script:
    link-vscode-remote:
      desc: Copy the vscode remote extension. Run on the remote machine.
      # This is based on:
      # https://stackoverflow.com/a/57601121/3064736
      # https://stackoverflow.com/a/56781109/3064736
      vars:
        prefix: ~/.vscode-server/bin
        commit:
          sh: code --version | head -2 | tail -1
      cmds:
        - mkdir -p {{.prefix}}
        # Replace the dest with a link to our dir.
        - ln -sinf $PWD/vscode/vscode-server-linux-x64 {{.prefix}}/{{.commit}}
        # To avoid having to click on "Install on server" for each extenstion, we
        # link the server extensions to the client extensions.
        - ln -sinf $PWD/vscode/data/extensions ~/.vscode-server/extensions
    • (The extension linking in the final command requires a shared filesystem, but isn't required if you're OK doing lots of clicking)
  • Then it works! The server finds the vscode-server-linux-x64 that we've linked to, and doesn't attempt to download anything.

@nasso
Copy link

nasso commented Dec 26, 2022

upping again: this is a major inconvenience as I use dev containers to make programming on Windows acceptable. right now, even though the image is available locally, i am unable to start the dev container when im not connected to the internet.

@KholdStare
Copy link

I have already posted this comment in issue #1802, but duplicating here.

It is quite ridiculous that even though I have connected to the same Docker container hundreds of times before and should presumably have a cached copy of the VSCode server locally, I cannot connect to it when offline. The fact that I need an internet connection for something that is entirely local is mind boggling.

If I am on the go, in an airplane, or in a cafe and don't want to use the public Wifi, tools should work without a constant internet connection.

Please please fix this, this is embarassing!

@Svalkash
Copy link

Svalkash commented Nov 8, 2023

+1 It has been over 3 years since this issue was opened, has there been any progress at all?

One way to get it done: https://linuxtut.com/en/af61a2593f4ed1d4085c/

It's still possible via modifying the JS file, but the link is outdated. You have to edit other lines right now.

@Crefok
Copy link

Crefok commented Oct 28, 2024

+1 It has been over 3 years since this issue was opened, has there been any progress at all?

One way to get it done: https://linuxtut.com/en/af61a2593f4ed1d4085c/

It's still possible via modifying the JS file, but the link is outdated. You have to edit other lines right now.

The Link is working for me, but the described method isn't. I got stuck at the "Download VS Code Server..." Message...

@joshspicer
Copy link
Member

joshspicer commented Oct 30, 2024

For those asking about the status in the Remote - SSH extension: The useLocalServer setting should help in a majority of cases. If the remote host isn't able to fetch the required server over the internet, it will attempt to scp the required server bits over from your local machine to the remote host. There seems to be some edge cases (#10344) and we'll look into those.

Edit : I've validated that "offline mode" does work end to end with the default settings. If you're having problems, you can also try disabling useExecServer at this time. Please let me know if you need to change any settings from the defaults, so I can improve the default case!

To validate, I "airgapped" a remote machine by denying all inbound/outbound access on a VM with iptables:
Image

With these settings I was able to connect to this remote machine from my Mac. In the logs you'll see an initial wget/curl fail (since the host is "airgapped") and then (by default) scp is used to copy over the bootstrapping server.

Having problems on windows? Take a look at the useLocalServer setting. This extension needs some way to get the bootstrapping program onto your remote machine.


Lastly, I'm seeing some comments in this thread regarding dev containers - please redirect that feedback to #10173 so its seen by the relevant folks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality plan-review PM-highlighted item determined to be P1 or P2 ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests