X forwarding though SSH not working: $DISPLAY not set
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
X forwarding though SSH not working: $DISPLAY not set
I am trying to redirect my display from a debian box that I ssh into to my laptop. I connect using
Code:
$ssh -vv -XC remote.host
and in the debug messages all I get about X is this
Code:
debug1: Requesting X11 forwarding with authentication spoofing.
Once I'm connected, X forwarding does not work. For example, when I try and start, say, xcalc, I get
Code:
$xcalc &
Error: Can't open display:
It seems that the problem is the $DISPLAY variable is not set on the remote machine (echo $DISPLAY doesn't return anything), but from what I read, sshd is responsible for setting this variable, as long as "X11Forwarding yes" is uncommented in the /etc/ssh/sshd_config file (which I made sure is true).
Is there any other reason why sshd won't open a display on the remote host?
Time to break out a tutorial and re create a headless O/S for use the way you want. I found that a properly configured box this way, is clever and valuable.
Apparently, disabling ipv6 in any way messes with X forwarding in ssh, it turns out it's an openssh issue. The posts suggest two workarounds:
1. add '-4' to the options passed to sshd in /etc/default/ssh
2. add 'AddressFamily inet' in /etc/ssh/sshd_config
I did the second one and it worked. Phew! This one was a toughy.
Apparently, disabling ipv6 in any way messes with X forwarding in ssh, it turns out it's an openssh issue. The posts suggest two workarounds:
1. add '-4' to the options passed to sshd in /etc/default/ssh
2. add 'AddressFamily inet' in /etc/ssh/sshd_config
I did the second one and it worked. Phew! This one was a toughy.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.