-
Notifications
You must be signed in to change notification settings - Fork 282
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
[Remote-SSH] X11 forwarding in integrated terminal won't work #267
Comments
I logged in with regular ssh client, checked the DISPLAY variable it set automatically and added it by hand to my launch.json configuration:
Works flawlessly. However, it should be done automatically just as the regular ssh client does it. I also noticed that the built-in ssh terminal doesn't source the EDIT: correction, I need to have a separate ssh terminal running in the background with X11 forwarding enabled, otherwise I am getting the connection refused error. |
VSCode Version: 1.34.0-insider |
Some more background. A common scenario is having the server in a local headless VM. Setting up X11 forwarding in ssh config as suggested in the closed #151 issue is not sufficient, because the "normal" (equivalent of) This problem is fairly acute in the vscode-cpptools ref #45 case. The default So the problem isn't just that you can't run |
I find another method which can temporary solve this problem. To begin with we should start a separate terminal which can use X-server flawlessly. Then we run the command |
I've tried this, it doesn't work. On my windows laptop, I have putty with X11 setup running an SSH terminal connection to my raspberry pi 3B+ and an Xming server. Through putty X11 works without problems. But while still running these both in the background if I do The same works perfectly in the putty ssh terminal though... Did anyone solve this? |
Another way to get X11 Forwarding for all integrated shells is to set |
I was trying to figure out the same issue and it turns out I trust OpenSSH too much.
Epic. |
I tried to create a workaround by making
If I then kill the remote vscode server and restart it, DISPLAY is at least set to some value, but that doesn't help because the original connection that set it has been closed. Maybe on Windows 10 it could work if you add Edit: |
My solution is to write
The reason why x11 forwarding always fails is that the |
I wrote an extension that automates the workaround wrobelda and EzioZz found: https://marketplace.visualstudio.com/items?itemName=spadin.remote-x11 When you open a remote SSH workspace, it starts up another SSH connection in the background with X11 forwarding enabled, grabs the I couldn't find any way to re-use the Remote SSH extension's authentication, so it only works with public key authentication. Having this built in to the Remote SSH extension would be much nicer. |
I tried every solution mentioned here with no success. External terminal works, but from vscode, even using the same display, I would get cannot connect to DISPLAY=xxxxxxx. What did work is opening a vnc session and put the display number in my .cshrc as: Since VcXserv was going to be another window anyway, to me this is equivalent... |
Public key authentication was disabled on our cluster by the administrator, so @ChaosinaCan's extension is not working. However, by manually repeating what is done in the extension, X11 forwarding will work in VS Code. Connect to the server manually in a terminal, grab $DISPLAY and export it in VS Code terminal. |
@ChaosinaCan Thanks a lot. You saved my day, it works flawless with Key based auth. That should be integrated in ssh remote plugin hopefully. |
Another idea: if one builds a full X server for vscode, together with the drag-n-drop file transfer and the integrated terminal- this would be the only program anyone will ever need for working remotely! |
This can be already done using guacamole. |
I would love to have this working in VSCode's Remote SSH extension! |
@ChaosinaCan Sorry for bothering you, I can work flawlessly with a new session by SecrueCRT or PuTTY in background like @wrobelda, but if I close the SecrueCRT or PuTTY, using your extension, it does not work, the failure info is "Could not connect to any X display.". Could you please provide a detailed config instruction on your https://marketplace.visualstudio.com/items?itemName=spadin.remote-x11 page? like how to config in vscode, how to config in remote-ssh computer, does your extension need to install in remote machine? etc. |
@xiaqian369 I just published an update with improved error logging and some troubleshooting steps in the readme. If you still can't get it working, please use my extension's issues page. Thanks! |
Setting > set DISPLAY=localhost:0.0
> ssh my-remote and it worked. |
I have an observation that probably goes to the heart of this problem. I'm not an expert in the ins and outs of ssh, but from the following observations, I have a hypothesis. When I connect to my virtualbox install of ubuntu from VSCode running in windows 10 and I run the following command:
In other words, it doesn't show that anybody is connected. Shouldn't it, at least, show that I'm connected?
It's as if the integrated terminal, or VSCode isn't actually connected, or at least, not in a persistent way. I hypothesize that this is why we need the background process of putty. With putty running in the background, the following works, and successfully opens the GUI text editor, gedit:
I suspect that the output is going through the background putty connection (it is the only one that is addressable?) and not the VSCode connection/non-connection (because it appears as if it doesn't actually exist). thoughts??? |
@zebraone100, have you tried setting |
What mostly works for me (VS Code version 1.47.0):
Now, I go to client2 and login using PuTTY with X11 Forwarding and check the display variable: $ echo $DISPLAY
localhost:10.0 And if I run xterm it shows up on client2's desktop. That's great. However, if I'm still logged in on client2 and start a new Remote SSH session from client1 and check the display variable I see it's not set correctly: $ echo $DISPLAY
localhost:10.0 sshd offers 10.0 to the first X-session, 11.0 to the second, and so forth. Since this is the second X-session it has the wrong display set (should be localhost:11.0) and when I launch xterm it comes up on the wrong client2 instead of client1! VSC seems to be caching this somewhere and ignoring it on subsequent connections. I can verify by disconnecting VS Code, opening up PuTTY on client1 with X11 Forwarding and see that it gets localhost:11.0. The big problem here is on a multi-user system I don't know which DISPLAY# I'm going to get. Might be 10.0 most days, but it could be 23.0 depending on how may people have X-sessions open. Is there a method of preventing this variable from being cached? I'm not sure if it's happening client-side or server-side. |
Per this issue comment from @roblourens the caching is happening on the remote server and is persisted between sessions:
Using the aforementioned kill command results in the desired behavior if not intuitive. Having a feature/setting to either not cache the DISPLAY variable, or re-read it, and/or a setting to kill the remote server on disconnect automatically would be ideal. Note: The remote server does shut down automatically, eventually, but the behavior until it does is non-intuitive for those in my situation. |
Any updates? |
I had a Xming-Server V6.9.0 running on my windows desktop. All common X11-apps (xclock, xeyes, xterm, ...) worked like a charm, but not VSC. I found out that the old Xming version has a missing feature or bug. As the new version is not for free anymore, I tried VcXsrv and all is fine now. If your X11forwarding works, you won't need any additional settings or configuration, just type |
I get "Failed to get DISPLAY: Error: Invalid cygwin unix socket path" while connecting, using Remote X11. If I set DISPLAY on server manually x11 forwarding works. But Remote x11 cant set it |
Hello @joelspadin Thanks for your extension. When I try, it gives me a timeout error as below. However, it works, if I connect from an external terminal with -X and then |
Being in linux it might be simpler, but I made it work with this lille hack. In your ~/bin folder make a file called
Make it executable. Then in your
Reconnect and enjoy |
Implementing this in #589 |
I found it just as easy to add export DISPLAY=:11.0 to my .bashrc FYI |
Steps to Reproduce:
xeyes
,eog
won't workDoes this issue occur when all extensions are disabled?:
If manually ssh to server in integrated terminal, x11 forwarding works fine.
I think maybe DISPLAY variable is not set properly in the failure case.
The text was updated successfully, but these errors were encountered: