Hey why cursor with ‘remote-ssh’ extension connection, not doing X11 forwarding. I tried both ways while putting -Y, -X in configs file and directly ssh -X name@server in remote connection panel. VSCODE works out of blue. Now i realised there is no way to install the MS remote ssh extension. It is so important for me, that i have to go work in vscode. Please look into it or if there is work around do let me know. Thanks
Steps to Reproduce
Just do ssh -X | - Y and check it, i tried on two machine and behavior is same no X11 forwarding,
Operating System
MacOS
Linux
Current Cursor Version (Menu → About Cursor → Copy)
We do not currently support X11 forwarding within Cursor, though this is something we’re looking at adding. It’s likely that the DISPLAY variable is not being set correctly when the ssh executable is being called. Could you start a separate terminal session outside of Cursor that does the x11 forwarding?
Another thing to try would be creating a custom wrapper for the SSH executable, which then sets the DISPLAY correctly. You can then instruct Cursor to use this custom ssh program via the setting remote.SSH.path. For example, save this script to ~/ssh-with-x-forwarding.sh
#!/bin/bash
# Function to detect and set DISPLAY variable
setup_display() {
# Check if DISPLAY is already set and valid
if [[ -n "$DISPLAY" ]]; then
echo "DISPLAY is already set to: $DISPLAY"
return 0
fi
echo "DISPLAY not set. Attempting to configure..."
# Detect if we're running in WSL
if grep -qi microsoft /proc/version 2>/dev/null; then
# We're in WSL
if grep -qi "WSL2" /proc/version 2>/dev/null || [[ -f /run/WSL/2 ]]; then
# WSL2 detected
echo "WSL2 detected. Setting up DISPLAY for X11 forwarding..."
# Get the Windows host IP from /etc/resolv.conf
WINDOWS_HOST=$(cat /etc/resolv.conf 2>/dev/null | grep nameserver | awk '{print $2}')
if [[ -n "$WINDOWS_HOST" ]]; then
export DISPLAY="${WINDOWS_HOST}:0.0"
echo "DISPLAY set to: $DISPLAY (WSL2 mode)"
else
# Fallback to localhost
export DISPLAY="localhost:0.0"
echo "DISPLAY set to: $DISPLAY (WSL2 fallback)"
fi
else
# WSL1 detected
echo "WSL1 detected. Setting DISPLAY to localhost..."
export DISPLAY="localhost:0.0"
echo "DISPLAY set to: $DISPLAY (WSL1 mode)"
fi
elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
# Git Bash or Cygwin on Windows
echo "Windows environment detected (MSYS/Cygwin)..."
export DISPLAY="localhost:0.0"
echo "DISPLAY set to: $DISPLAY"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Native Linux
echo "Native Linux detected..."
export DISPLAY=":0"
echo "DISPLAY set to: $DISPLAY"
else
# Unknown environment, try common default
export DISPLAY=":0"
echo "Unknown environment. DISPLAY set to: $DISPLAY (default)"
fi
# Test if X server is reachable
echo -n "Testing X server connection... "
if timeout 2 xset q &>/dev/null; then
echo "SUCCESS! X server is reachable."
# Offer to save the working configuration
if [[ -z "$SSH_X11_NO_SAVE" ]] && [[ -w "$HOME" ]]; then
echo ""
echo "Tip: To make this DISPLAY setting permanent, add to your shell profile:"
echo " echo 'export DISPLAY=$DISPLAY' >> ~/.bashrc"
echo "Or for this session only:"
echo " export DISPLAY=$DISPLAY"
fi
else
echo "WARNING: Cannot reach X server at $DISPLAY"
echo "Make sure an X server is running:"
echo " - On Windows: VcXsrv, X410, Xming, or MobaXterm"
echo " - On Linux: Usually running by default with desktop environment"
echo " - On macOS: XQuartz"
echo ""
echo "For WSL2 with VcXsrv:"
echo " 1. Start VcXsrv with 'Disable access control' checked"
echo " 2. Allow it through Windows Firewall"
echo " 3. Use -ac flag when starting VcXsrv for better compatibility"
echo ""
echo "Troubleshooting:"
echo " - Try: export DISPLAY=localhost:0.0"
echo " - Or for WSL2: export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '{print \$2}'):0"
fi
echo ""
}
# Setup DISPLAY variable
setup_display
# Determine X11 forwarding mode
if [[ "$SSH_X11_TRUSTED" == "no" ]]; then
X11_FLAG="-X" # Untrusted (more secure)
echo "Using untrusted X11 forwarding (-X)"
else
X11_FLAG="-Y" # Trusted (more compatible)
echo "Using trusted X11 forwarding (-Y)"
fi
echo "Starting SSH with X11 forwarding enabled..."
echo "DISPLAY=$DISPLAY"
echo ""
# Execute SSH with X11 forwarding and pass all arguments
exec ssh $X11_FLAG "$@"
Then, make it executable (chmod +x ~/ssh-with-x-forwarding.sh) and set the remote.SSH.path setting to this filepath.
sadly, the workaround suggested by you does not work on ubuntu machine for me.
usage: ase [-h] [–version] [-T] {help,info,test,gui,db,run,band-structure,build,dimensionality,eos,ulm,find,nebplot,convert,reciprocal,completion,diff,exec} … ase: error: TclError: couldn’t connect to display “localhost:18.0” To get a full traceback, use: ase -T gui …
Login on server directly, works fine using same python env and also through vscode it also works fine.
Hi @shera-amit, we found a bug in our Remote SSH extension that overrode the DISPLAY variable, which broke x11 forwarding. We fixed this in version 1.0.29 of the Remote SSH extension. Could you try upgrading to the latest version of the extension and share whether this works for you? Thanks!