X11 Forwarding over ssh - Could not find ':' in DISPLAY: 1

9,559

I'll give a generic answer here, because other people might be struggling to setup X forwarding on a Mac here. I think in your specific case, try to run ssh from XQuarts instead of running it from the terminal. Also make sure you have XForwarding set on the serverside and restart sshd after adjusting it.

Prerequisites to run X applications on OS-X:

  • You need to have XQuartz installed on the client side (check that it's working for your account by running XQuarts and starting a local terminal)
  • You need to allow XForwarding on your server. Set the X11Forwarding option (most commonly found in /etc/ssh/sshd_config): X11Forwarding yes (don't forget to restart the ssh server after editing the sshd_config file).
  • Your sshd server should be running on the server side.
  • Your firewall (on both ends) should allow for traffic over port 22.

Running X over ssh:

  1. Start a XQuartz terminal by starting XQuartz and pressing +n
  2. In the terminal type: ssh -X [username]@[servername] (you can also use -Y instead of -X)
  3. You should be logged in to your server. Try xeyes for example to have X look back at you.

Troubleshooting:

  • "Connection refused": check your firewall settings (on both ends) and check if the ssh server (sshd) is running on the receiving side.
  • $DISPLAY errors: ssh should be taking care of setting the $DISPLAY variable. If your are running from XQuartz, this means that (for one reason or another) ssh wasn't able to setup a Xforwarded session. Check any errors in your log files (particulary on the server side) and try ssh with verbose output -v or even -vv or -vvv and look for clues). Don't tamper with the $DISPLAY setting yourself, because it's the effect of ssh not being able to establish a tunnel, not the cause.
Share:
9,559

Related videos on Youtube

psteelk
Author by

psteelk

Updated on September 18, 2022

Comments

  • psteelk
    psteelk over 1 year

    I'm trying to connect from my mac (Xquartz installed) to a ubuntu server. I use the -Y option with ssh. When I ssh to the server and run any graphical application for example xclock, I get the following error

    $xclock
    Could not find ':' in DISPLAY: 1
    Error: Can't open display: localhost:10.0
    

    X11 forwarding is set in sshd_config

    $ grep -i X11Forward /etc/ssh/sshd_config
    # Setting X11Forwarding to "yes" permits encrypted X connections.
    X11Forwarding yes
    

    and,

    $ echo $DISPLAY
    localhost:10.0
    

    Can someone help me in this regard.

  • psteelk
    psteelk over 9 years
    Thanks ! In my case, I did not logout and login for the X to take effect and because of which it was failing.