25

I've always wanted to get X11 Forwarding to work with PuTTY, and the X Window System I'm using is Xming. When I have Xming running and I establish a new connection to my server, I receive the following after a command:

$ firefox
PuTTY X11 proxy: wrong authentication protocol attemptedPuTTY X11 proxy: wrong authentication protocol attemptedError: cannot open display: localhost:10.168

$ google-chrome
PuTTY X11 proxy: wrong authentication protocol attempted
(google-chrome:7083): Gtk-WARNING **: cannot open display: localhost:10.168

$ gedit
PuTTY X11 proxy: wrong authentication protocol attempted
** (gedit:6990): WARNING **: Could not open X display
PuTTY X11 proxy: wrong authentication protocol attemptedCannot open display:
Run 'gedit --help' to see a full list of available command line options.

$ gnome-system-monitor
PuTTY X11 proxy: wrong authentication protocol attempted
** (gnome-system-monitor:7024): WARNING **: Could not open X display
PuTTY X11 proxy: wrong authentication protocol attempted
(gnome-system-monitor:7024): Gtk-WARNING **: cannot open display: localhost:10.168

How do I fix these errors and get X11 Forwarding to work as a whole?

2
  • How to fix this ?
    – user568109
    Commented Nov 20, 2013 at 5:57
  • You should create an account, ask a new question, and then link it here so that I can see it. Commented Nov 20, 2013 at 18:51

5 Answers 5

14

Copied from: http://www.math.umn.edu/systems_guide/putty_xwin32.html (dead link: archive 2013-05-23)

Configuring Putty

  • Add Unix hostname
  • Switch Protocol to SSH
  • Type name of session in saved sessions
  • Click 'Save'

  • Expand the 'SSH' tab from the 'Category' list
  • Choose 'X11' from 'SSH' list
  • Check 'Enable X11 Forwarding'

  • Choose 'Session' from 'Category' list
  • Click 'Save'

Starting the X Server on Windows

Configuring Xming

Just run "All Programs > Xming Xming" and it should work if you've got PuTTY configured.

Connecting

  • Start Xming
  • Start Putty
  • Double click on the saved session you want

  • Enter username and password as requested
  • You should now be able to run X applications from the host on your local desktop

EDIT: To fix the wrong authentication protocol attempted error, try enabling “ForwardX11Trusted yes” in the /etc/ssh/sshd_config file and then restart the OpenSSH server.

8
  • I literally read the exact same guide (it's how I found out about Xming), but found it completely useless otherwise because it either told me things I already knew or could figure out just by running the two programs. Commented May 7, 2013 at 2:28
  • I was kind of able to get X11 forwarding working, but I suppose this answer is the limit as to what you can do for it. I don't know why my question took a -1 though... Commented Oct 19, 2013 at 22:34
  • How does it solve the problem. It is just a tutorial to configure x over ssh.
    – user568109
    Commented Nov 20, 2013 at 5:56
  • @user568109 If you follow these directions and then attempt to call any GUI-based program, it will display locally.
    – Kruug
    Commented Nov 20, 2013 at 14:52
  • 11
    ForwardX11Trusted us a client-side setting. Putting this into sshd_config will have no effect at best and will prevent the SSH server from starting up at worst. -1. This is sshd_config versus ssh_config if you are looking for man pages. Commented Aug 7, 2014 at 0:02
17

I had 2 problems and found this question had the closest problems to mine, so thought my solution would be helpful to others who get here, trying to fix the same problem as me. My system has Cygwin/X (xinit 1.3.4-5), and PuTTY (0.64). I managed to get to the bottom of it by setting both --listen tcp on the local startxbin and passing the path to .Xauthority to putty.

Firstly, in reference to the "PuTTY X11 proxy: unable to connect to forwarded X server: Network error: Connection refused" error, you need to make the X session listen for connections: Open a cygwin terminal and edit /usr/bin/startxwin find the line...

defaultserverargs="-multiwindow"

and change it to...

defaultserverargs="-multiwindow -listen tcp"

Secondly, in response to the "Authorization required, but no authorization protocol specified" error, you need to make putty use the correct xauth tokens (something strange seems to go on inside putty so xauth list locally doesn't give tokens that the forwarded connection can use by passing them in xauth add <token>, they seem to need to be set by PuTTY on connection, in order for them to work).
Find the path, in the windows domain, where your ~/.Xauthority file is by running (in cygwin terminal again)

cd ~
explorer .

Check out the properties on the .Xauthority file and make a note of the Location to it (select it and press CTRL+C to put it in clipboard).

Start PuTTY as in the example above (copied from http://www.math.umn.edu/systems_guide/putty_xwin32.html)

On the 'Options controlling SSH X11 forwarding' page, you should have 'Enable X11 forwarding' checked, and 'MIT-Magic-Cookie-1' set as the protocol.
Under the 'X authority file for local display' field, click Browse and using the Location to the .Xauthority file you made a note of earlier, find the .Xauthority file. Click Open to populate the field, then go back to Session (in PuTTY configuration) and save the session. Then you can click open.

It should now allow you to connect.

1
  • 3
    I also needed to set the X authority file for local display to point to my .Xauthority folder in my cygwin home directory. Thank you! Commented Oct 5, 2015 at 21:24
3

My steps, using DISPLAY 20 (since the default may be already used)

On Windows,

C:\Program Files (x86)\Xming>xming :20 -ac

On Putty, create reverse port forwarding e.g. 6020 in remote to same port in local windows:

enter image description here enter image description here

On the unix side:

export DISPLAY=:20
<your visual app>

How does it work?

  • Unix side (X clients) use the DISPLAY variable to figuure the port out, display 20 is on port 6020.

  • The display server (XMing) also needs to listen on port 6020 (this is the :20 argument to xming).

  • Putty reverse port forwards the data from localhost:6020 to our windows server (same port). It is a reverse port because traffic is forwarded from destination to the source of the connection.

  • The "-ac" argument makes Xming to accept incoming connections without security.

Only use Xming option -ac or 'xhost +' on trusted networks, never on public ones i.e. be careful as they grant access to everyone. The X protocol network traffic is only encrypted if using X-Forwarding with SSH and this is therefore the recommended method for access control, all others method are potentially unsafe (e.g. using xhost or xauth and especially working via the defunct Telnet or Rsh/Rlogin protocols).

So you must ensure that your windows port 6020 is not reachable by any host (except localhost through the reverse port).

3
  • Great! This doesn't require any SSH X11Forwarding settings. Works great in my case on Windows with vcXsrv. Thanks!
    – Cleric
    Commented Oct 26, 2022 at 9:21
  • why does this work?! Commented Jul 25 at 22:46
  • Hi Sterling, I'm updating my answer to clarify things up (hopefully). Commented Aug 7 at 18:52
1

You can

xauth list

then

xauth add <your display>
3
  • 2
    Command line is xauth add dpyname protoname hexkey. Commented May 7, 2013 at 2:37
  • oddly, that didn't work on my forwarded putty connections.
    – sibaz
    Commented Jan 20, 2016 at 11:03
  • At least this one gives some direction to the issue. I did not have xauth installed on the server side. Installing and configuring it sort of fixed the issue.
    – jazaman
    Commented Apr 26, 2020 at 19:53
1

Kruug’s solution worked for me with few additional steps as given below.

As I was logging in with ec2-user and later switching to oracle user. Make sure the .Xauthority file is copied over to oracle user’s home.

cp /home/ec2-user/.Xauthority /home/oracle/

How did I test? I installed xclock

yum install xclock

Then I ran xclock (Wait for few seconds, if you are getting a small pop-up window of analog clock, all good)

xclock

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .