X11 display variable as 0 opens on machine itself on not ssh connection

Issues related to applications and software problems
Post Reply
KaunasLT
Posts: 3
Joined: 2024/03/21 20:44:13

X11 display variable as 0 opens on machine itself on not ssh connection

Post by KaunasLT » 2024/03/22 12:44:52

Hello.

i am struggeling to get X11 forwarding gui application to my windows machine over ssh. I know the windows part HAS WORKED at some time but now on a free centos install i cant display gui apps and returns with error cant open display.

what i have done.

installed xorg auth, xorg fonts, xorg utils. enable X11 forwarding on putty, x11forwarding yes, x11uselocalhost no.
xauth generate also done.

due to anothers program having license problem due to the hostname of centos being localhost i messed arround in the hostname config and suspect that could be causing this.

under /etc/hostname i deleted everything and just called it "philip". nothing else
and under /etc/hosts i have
127.0.0.1 localhost localhost.localdomain philip
and
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
using command hostnamectl gives me the static hostname as philip.

Again i messed around with this due to a programs licesing not accepting a system being name localhost.

on the windows doing in ssh terminal echo $display gives blank statement.
setting display variable as :=0 make xclock start on the centos machine instead of forwarding the gui to the windows

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: X11 display variable as 0 opens on machine itself on not ssh connection

Post by jlehtone » 2024/04/08 09:08:57

One thing that is required is that the ssh client is told to enable the X11 forwarding:

Code: Select all

[jlehtone@here ~]$ ssh there
there:0:~$ echo $DISPLAY

there:0:~$ exit
logout
Connection to there closed.
[jlehtone@here ~]$ ssh -X cotton
there:0:~$ echo $DISPLAY
localhost:10.0
The second thing is that there must be X11 server running in the Windows machine.

Whoever
Posts: 1361
Joined: 2013/09/06 03:12:10

Re: X11 display variable as 0 opens on machine itself on not ssh connection

Post by Whoever » 2024/04/08 22:35:45

KaunasLT wrote:
2024/03/22 12:44:52

setting display variable as :=0 make xclock start on the centos machine instead of forwarding the gui to the windows
Display ":0" is always going to be the local display and not anything tunnelled through ssh. When you have logged in with X Forwarding enabled, the value of display will be something like:
localhost:10.0

Once you get that after logging in, you can change your DISPLAY variable to "phillip:10". Get the exact number from "echo $DISPLAY".

Note that it is upper case $DISPLAY, not lowercase $display.

X Forwarding needs to be enabled on both the server and the client.

Post Reply