Open davidanthoff opened 4 years ago
@AgFlore can you verify that this workaround works? At least from my testing, it does not seem to remove the necessary argument.
It works for me, on version 1.80.0 (660393de); still seems good on 1.80.1 (74f6148e).
One comment:
./vscode-server
should probably be/.vscode-server
Ahhhhh yes you're right, sorry for the typo. My workers are all in an internal network (where one cannot copy data out), so the snippet was a hand-type-copy and was prone to mistakes like this.
One workround for now (only for users who wants the remote-server persistent FOREVER, not for users who wish to change the timeout value):
Neat @AgFlore! Does this work even when VS Code client is closed?
One workround for now (only for users who wants the remote-server persistent FOREVER, not for users who wish to change the timeout value):
Neat @AgFlore! Does this work even when VS Code client is closed?
Yes. With --enable-remote-auto-shutdown
removed, the server processes can only be killed manually. like if you upgraded your client, you need to kill the old server by yourself, or it will be running there forever.
One workround for now (only for users who wants the remote-server persistent FOREVER, not for users who wish to change the timeout value):
vscode starts the remote server by launching
sh <vscode-server-bin-path>/bin/code-server --start-server --host=127.0.0.1 --accept-server-license-terms --enable-remote-auto-shutdown --port=0 --telemetry-level all --connection-token-file <path-to-token-file>
in your default shell (/bin/bash
in my case) after it established the SSH connection.Therefore, just remove the
--enable-remote-auto-shutdown
argument, and the server will run without the idle timeout. This can be achieved by a customised wrapper forsh
. My version goes like:#! /bin/bash args="$@" ignore_me='--enable-remote-auto-shutdown' if echo "$@" | grep -q -- "/.vscode-server"; then if echo "$@" | grep -q -- "$ignore_me"; then args=$(echo "$@" | sed "s/$ignore_me//g") fi fi /usr/bin/sh $args
And then
export PATH=<path-where-you-put-that-wrapper>:$PATH
in.bashrc
(or into vscode's ssh-config, if you dislike polluting your shell environment). Now vscode will launch the remote-server without enabling the annoying idle-shutdown.
Could you explain this a bit more? `
Tried to add it, but without any luck.
And then
export PATH=<path-where-you-put-that-wrapper>:$PATH
in.bashrc
(or into vscode's ssh-config, if you dislike polluting your shell environment). Now vscode will launch the remote-server without enabling the annoying idle-shutdown.Could you explain this a bit more? `
* How do we put this into vscode's ssh-config? * Should this be on host or client?
The simpler way of doing this is modify your server's ~/.bashrc
, add that line of exporting PATH, so that its bash shell automatically uses your modified version of sh
.
However, if you mind modifying that global bash profile, you may also configure the client so that it loads the specified .bashrc
you want. you may utilise the RemoteCommand
option, changing it to like (generated by copilot, haven't tried out myself yet.)
Host myserver
HostName example.com
User myusername
RemoteCommand bash --rcfile /path/to/.bashrc
check https://github.com/microsoft/vscode-remote-release/issues/4474 for reference about utilising RemoteCommand
.
OK looks like I resolved this issue for myself. I want to tell you how I did it, so you could learn on my experience.
Of course, this is not a solution for this issue and cannot be used to close this issue :) I think it should be integrated into vscode itself. That will fix this whole issue.
I use Azure Virtual Desktop. (Actually, this is DevBox https://azure.microsoft.com/en-us/products/dev-box) with Windows on local notebook and remote machine, and I have only RDP connection to remote machine, without direct access to it (is uses gateways).
I created WSL2 machine on remove Windows OS, started SSHD server on it, port forwarded SSH port to local machine, and now I have uninterruptible SSH to remove machine's WSL2.
(please don't ask me why I have Windows and can't just install Ubuntu :) )
TLDR: use devtunnels ( https://aka.ms/devtunnels ), proxy your SSH port via it, use localhost to connect to remotely forwarded port in vscode, add Timeout to ssh config for that host.
devtunnels ( https://aka.ms/devtunnels ) are using not really usual SSH, but it's own implementation, dev-tunnels-ssh ( https://github.com/microsoft/dev-tunnels-ssh/ ), which states this in the README:
Supports reconnecting a disconnected session without disrupting channel streams.
So, after your computer goes from sleep, there is a delay about 5 seconds for WIFI, and some extra 3 seconds for reconnecting.
This breaks SSH, since default timeout is not that high. We gonna pipe those numbers up, by using this SSH config entries
ServerAliveInterval 60
ServerAliveCountMax 120
60 seconds is high, it it will be enough. Plus, I will show how to specify this config specifically for your vscode host.
devtunnel user login
. Use same account on both machines.devtunnel host -p 22 -p 8080
Ready to accept connections for tunnel: THEREISNOSPOON
(THEREISNOSPOON is example ID)devtunnel connect THEREISNOSPOON
Add New SSH Host...
ssh -C remoteuser@127.0.0.1 -p 22
(-p here because I'm using not 22 but 2222 port actually, but this makes no sense in this context)~/.ssh/config
on ubuntu and %HomePath%/.ssh/config
on Windows )From:
Host 127.0.0.1
HostName 127.0.0.1
Compression yes
User remoteuser
Port 22
To:
Host DEVBOX
HostName 127.0.0.1
Compression yes
User remoteuser
Port 22
ServerAliveInterval 60
ServerAliveCountMax 120
P.S. Sorry for too much info, I wanted it to be easily searchable on the internet.
CC: @davidanthoff as topic starter
RELATED: #1790
Great write up above, but you'll also want to tweak ClientAliveCountMax/ClientAliveInterval on the server, as the defaults don't last that long.
As you mentioned Ubuntu, see their manpage for the specific version of openssh.
tldr: change ClientAliveCountMax/ClientAliveInterval on the server to be a little higher than your client.
Related on Stack Overflow: UNIX screen like behavior for Visual Studio Remote Development
For the time the code server keeps running, either the default time-out or when keeping it running forever using this solution https://github.com/microsoft/vscode-remote-release/issues/3096#issuecomment-1617150814, how can I reconnect to it?
For me even if on the host the code server and all related processes are still running, when I reconnect to the host (even if the ssh connection is only interrupted for a few seconds), it starts a second code server on the host instead of reconnecting to the old one.
Has anyone tried a simpler way to create a tunnel with https://code.visualstudio.com/docs/remote/tunnels ? I used it on Remote window, but it only gave me access to my local workstation. Maybe it's worth a shot to install VSCode CLI on remote machine and use it there?
I'm only worried that this "server" code
that you can install manually is slightly different from code
command that is made available when you run remote connection. I wouldn't like to lose the ability to quickly open files in my editor.
tl;dr doesn't work like we expected
I tried it. It's kind of scary, but fairly simple. The important thing is that You need to install code on the server (e.g. the deb package). The code
command available after connecting to a machine doesn't work at all. The code server installed by remote connection plugin works, but it doesn't print any URIs to connect to.
After you run code tunnel
it will ask you to authenticate with your GitHub. This is scary, because you give your server access to your GitHub. Normally, you give it access anyway so I guess there is nothing to worry about (above what you should normally worry about :P). Let's assume your server is secure.
Then you can click the link to open VSCode in browser and again authenticate to gain access to the machine. I did it, and the machine also showed up in my remote explorer on the locally installed VSCode. When I closed the browser I could still use my remote connection from my PC. I guess you could try to skip this step and manually add this remote server to your local VSCode by URI, without opening the browser.
The browser version works nicely, because it preserves all windows and terminal sessions. Unfortunately, desktop VSCode treat this connection slightly differently, because it ties all editor and terminal windows to specific desktop instance. Once you close the VSCode window all progress is gone.
Any updates on official support for this feature?
hey, any updates here?
Yeap, we need this feature!! And there must also be support for Jupyter Notebooks
AWS Cloud9 already has this persistent feature for years and years now. Gitpod also provides this via their own extension, however, it's tied to Gitpod servers (arguably cheaper than Azure Dev Box) and you need to configure timeouts to be higher than default (depending on your usecase). So, the possibility is there, it's just not getting enough attention. I wonder why this stays stall for a long time, and yet it's got lots of demands.
4 years later, and this issue still open.
I think (but I still have not tested) that here is the problem
I think (but I still have not tested) that here is the problem
Interesting finding. So you're saying that you've tested it and it became persistent afterwards?
Any updates on this? For remote AI training on GPU machines this is going to be such a huge quality of life improvement.
Another vote for this!
For those who consider persistent ssh session as a critically important feature, you can also try JetBrains Fleet. By utilizing its collaboration feature(which is similar to vscode-tunnel), it keeps terminals and debugging sessions after client being closed. Though it's not open source, and it does not even support plugins.
I also think we need this. And the worst part is how it is so easy to implement by making the stupid --enable-remote-auto-shutdown optional from the settings yet it has been 4 years and no progress.
Is there a confirmation from the team that PRs with a flag in extension settings for --enable-remote-auto-shutdown
would be accepted?
@ionagamed The microsoft remote development extensions are not open source (see #30). From my exploration, the struct CodeServerArgs in code_server.rs needs to have an additional Option
That would be a great addition
I want this too.
this would be great!
Any news regarding this feature? This would be a great improvement. In my usecase, when I build a devcontainer, it might take hours, and I don't want to keep VSCode open on my laptop for that long - I'd like to close VSCode, do something else on my laptop, and reattach peoredically to check the progress. For now, as a workaround, I'm inspecting logs of devcontainer and running them manually with nohup
, but this approach has certain minor short-comings.
Any news regarding this feature? This would be a great improvement. In my usecase, when I build a devcontainer, it might take hours, and I don't want to keep VSCode open on my laptop for that long - I'd like to close VSCode, do something else on my laptop, and reattach peoredically to check the progress. For now, as a workaround, I'm inspecting logs of devcontainer and running them manually with
nohup
, but this approach has certain minor short-comings.
I've been using tmux
to get around the lack of persistent sessions. tmux
is utility that allows you to start detached terminals, which enables you to smoothly reconnect to them after restarting the editor.
A lot of users of our Julia extension love the remote SSH features, they are super useful in a scientific research computing context!
One thing that has come up a lot lately, though, is that folks want an ability to have a persistent session on a server that they can disconnect from and then reconnect to way later.
The scenario is essentially something like this:
I think this might be related to https://github.com/microsoft/vscode-remote-release/issues/440, but what I'm really asking for is not just an option to change the timeout, but some way to make the timeout infinit, so that the server session never shuts down.
This might also require some kind of UI, maybe a command like "Disconnect but keep server alive" or something like that, not sure.