14
votes

I am testing out Google Compute Engine (with an instance running Debian), and I have trouble using X11 forwarding through ssh. To connect to my instance I use

gcloud compute ssh --ssh-flag="-X" instance-name

While connecting I get the following response to the screen

X11 forwarding request failed on channel 0

and X11 forwarding does not work. Is this a problem of proper configuration of shh or perhaps something related to GCE?

I hope someone can help me get X11 forwarding up and running

4
You can also use vncserve. Make sure you have something like GNOME Desktop installed on the instance. Create a firewall rule to open port 5901, start vncserve on the host/instance, it asks you to set a password, then use a vnc client on your local machine (Screen Share on Mac OS X). I thought I wanted to do X11 forwarding until I learned how to do this. End result: UI running on the instance that I control locally.mauricio777
I meant: vncserver, not vncserve (Missing the "r" in my original comment)mauricio777

4 Answers

10
votes

I believe that you’re affected by a Debian bug, that prevents you from being able to use X11 forwarding.

Adding AddressFamily inet in /etc/ssh/sshd_config and restarting the SSH server should work.

If it still doesn't work, you could you try to add X11UseLocalhost no in the same file and restart the SSH server again.

5
votes

I had to do two things.

Install xauth:

sudo apt-get install xauth

and modify /etc/ssh/sshd_config by adding the following on a new line: X11UseLocalhost no

Bounce the ssh daemon

sudo /etc/init.d/ssh restart

Reconnect with the -X flag and you should be good to go.

0
votes

if you want to use X forwarding it should be enabled on both sides. On the server side you need to specify ForwardX11 yes in ~/.ssh/config. See This answer for more requirements to have X11 forwarding working.

0
votes

on a macos I had to download xquartz (open source) software. I opened a xquartz terminal and ssh'd using the glcoud suite command.

this is what I did to fix this:

  • downloaded gcloud suite to be able to ssh using gcloud
  • downloaded xquartz open source software. restart computer after downloading.
  • updated /etc/ssh/etc_config on the target server. I have the following set, but not sure which one works. restart ssh daemon/server after updating.

ForwardAgent yes

ForwardX11 yes

X11UseLocalhost no

#ForwardX11Trusted yes this is commented

  • opened xquartz terminal and typed in the gcloud ssh command with the -X flag e.g. gcloud beta compute ssh --ssh-flag="-X" --zone "[zone]" "[instance]" --project "[project]"
  • this made me able to connect to my gcp instance in a xquartz terminal.
  • after I connected, I tried the command that I was trying to do and it worked.