xhost:  unable to open display ""

Quanwen Zhao

    Hello, experts

     

    Yesterday I installed Oracle Linux 7.5 on VirtualBox 5.2.18, during this period I used the "Minimal Install" for OL, and then I want to use VNC to connect to the GUI, so I installed this RPM package - VNCpilot (you can download it from here, VNCpilot for OL/EL 7 and some related DOCS from here, VNCpilot - Simple And Secure Remote Access).

     

    Unfortunately after I configure VNCpilot, and I always don't login to GUI via vncviewer, the following are my some operation steps,

     

    [root@Oracle18c software]# rpm -ivh vncpilot-1.0-1.el7.x86_64.rpm
    error: Failed dependencies:
            dejavu-fonts-common is needed by vncpilot-1.0-1.el7.x86_64
            dejavu-sans-fonts is needed by vncpilot-1.0-1.el7.x86_64
            dejavu-sans-mono-fonts is needed by vncpilot-1.0-1.el7.x86_64
            dejavu-serif-fonts is needed by vncpilot-1.0-1.el7.x86_64
            gnome-terminal is needed by vncpilot-1.0-1.el7.x86_64
            metacity is needed by vncpilot-1.0-1.el7.x86_64
            tigervnc-server is needed by vncpilot-1.0-1.el7.x86_64
            xorg-x11-apps is needed by vncpilot-1.0-1.el7.x86_64
            xorg-x11-utils is needed by vncpilot-1.0-1.el7.x86_64
    

     

    [root@Oracle18c software]# yum install -y dejavu-fonts-common
    [root@Oracle18c software]# yum install -y dejavu-sans-fonts
    [root@Oracle18c software]# yum install -y dejavu-sans-mono-fonts
    [root@Oracle18c software]# yum install -y dejavu-serif-fonts
    [root@Oracle18c software]# yum install -y gnome-terminal
    [root@Oracle18c software]# yum install -y metacity
    [root@Oracle18c software]# yum install -y tigervnc-server
    [root@Oracle18c software]# yum install -y xorg-x11-apps
    [root@Oracle18c software]# yum install -y xorg-x11-utils
    

     

    [root@Oracle18c ~]# rpm -ivh /software/vncpilot-1.0-1.el7.x86_64.rpm
    Preparing...                          ################################# [100%]
    Updating / installing...
       1:vncpilot-1.0-1.el7               ################################# [100%]
    

     

    [root@Oracle18c ~]# vncpilot --create -shared -size=1280x800
    VNCpilot 1.0. Copyright (c) 2018 Dude! @ Oracle Community.
    Free under the GNU General Public License. See vncpilot --help for info.
    
    
     Service Summary:
    
    
     VNC service unit:    /etc/systemd/system/vncserver@:95.service
     VNC attributes:      alwaysshared, 1280x800x16, localhost, vncauth
     Service status:      enabled, active
    
    
     TCP/IP address  | TCP port | Port status | Username | Password
     192.168.210.10  |   5995   |  listening  | vnc-89D  | EeB-7XT-Mbn
    
    
    
    
      Note:  1. Use SSH on a PC running the VNC viewer to forward a local TCP
                port (5901) to the remote TCP port of the VNC service (5995):  
                $ ssh -L 5901:localhost:5995 vnc-89D@192.168.210.10
    
    
             2. Connect the VNC viewer to localhost (127.0.0.1):
                $ vncviewer localhost:5901
    
    
     For help: <https://community.oracle.com/docs/DOC-1024831>
    

     

    [root@Oracle18c ~]# vncpilot -s
    VNCpilot 1.0. Copyright (c) 2018 Dude! @ Oracle Community.
    Free under the GNU General Public License. See vncpilot --help for info.
    
    
     Service Summary:
    
    
     VNC service unit:    /etc/systemd/system/vncserver@:95.service
     VNC attributes:      alwaysshared, 1280x800x16, localhost, vncauth
     Service status:      enabled, active
    
    
           TCP/IP address  | TCP port | Port status | Username
           192.168.210.10  |   5995   |  listening  | vnc-89D
    

     

    You can take a look at  two screenshots as follows (BTW I have run this icon of "Xmanager - Passive" on taskbar),

    1.png

    2.png

    Could you help me to solve it? Thanks a lot.

     

    Best Regards

    Quanwen Zhao

      • 1. Re: xhost:  unable to open display ""
        handat

        You need to set the display, eg export DISPLAY=:0.0

        However, most modern clients should be able to set the DISPLAY automatically unless you are missing something.

        I saw you installed xorg-x11-apps and xorg-x11-utils but you may be missing xorg-x11-xauth and xorg-x11-fonts-*

        • 2. Re: xhost:  unable to open display ""
          Nik

          Hi.

          Your screenshots not correspond what you write...

           

          Resolve one problem on one step.  Xmanager - use other protocol and  different from VNC.

          You not need use xhost for VNC.

           

          You write  that start ssha with redirected ports, but on screenshot start  vncviewer on localhost:5995.

           

          You need: 

          1. Start VNCserver on Linux.  ( you already do it).

          2.  Start VNCviewer on PC.

              ( You can connect to 192.168.210.10:5995 or

                 to localhost:5901   when started ssh with port redirection ).

           

           

          Regards,

             Nik      

          • 3. Re: xhost:  unable to open display ""
            Dude!

            Why have you not been following the instructions?

             

            rpm -ivh vncpilot-1.0-1.el7.x86_64.rpm 

            Why did you use rpm and and not yum to install?

             

            Please see  3.3     Installation

             

            Where did you read anything the need to use xhost? or connecting the vncviewer to port 5995?

            From your screenshots I can see that the vnc service was setup properly. So you simply do the following.

             

            Note:  1. Use SSH on a PC running the VNC viewer to forward a local TCP 

                            port (5901) to the remote TCP port of the VNC service (5995):   

                            $ ssh -L 5901:localhost:5995 vnc-89D@192.168.210.10 

             

                       2. Connect the VNC viewer to localhost (127.0.0.1):  

                           $ vncviewer localhost:5901 

             

            So after you establish a ssh connection from your PC to your remote server as shown, you connect to the vncviewer to localhost port 5901. You start vncviewer on your PC, not the remote host.

             

            Please see 2.3     Video Demo

             

            The concept is the same, regardless of your PC desktop system.

            • 4. Re: xhost:  unable to open display ""
              Dude!

              I suggest you do the following as user root:

               

              1. run "vncpilot -d"

              This will complete remove the VNC service.

               

              2. run "vncpilot -c"

              This will setup the VNC service and show you the password.

               

              3. Start a VNC client or viewer on your Windows PC desktop and connect it to locahost port 5901. If you need instructions, please see Microsoft Windows

              • 5. Re: xhost:  unable to open display ""
                Quanwen Zhao

                Hello, Dude!

                 

                Thanks for supplying so cool and simply RPM Tool vncpilot to ODC.

                 

                I know that it has generated VNC Port 5995 via "vncpilot -c" and actually created a user "vnc-89D", I can see from the instruction below,

                 

                [root@Oracle18c ~]# ps -ef | grep Xvnc
                vnc-89D   2318     1  0 12:38 ?        00:00:00 /usr/bin/Xvnc :95 -auth /home/vnc-89D/.Xauthority -depth 16 -desktop Oracle18c:95
                                                                (vnc-89D) -fp catalogue:/etc/X11/fontpath.d -geometry 1280x800 -pn -rfbauth 
                                                                /home/vnc-89D/.vnc/passwd -rfbport 5995 
                                                                -rfbwait 30000 -alwaysshared -localhost -SecurityTypes=vncauth
                root      2547  1476  0 12:52 pts/1    00:00:00 grep --color=auto Xvnc
                

                 

                I eventually understand the two configuration steps as follows,

                 

                Note:  1. Use SSH on a PC running the VNC viewer to forward a local TCP

                                port (5901) to the remote TCP port of the VNC service (5995):  

                                $ ssh -L 5901:localhost:5995 vnc-89D@192.168.210.10

                 

                           2. Connect the VNC viewer to localhost (127.0.0.1): 

                               $ vncviewer localhost:5901

                 

                I can log into "vnc-89D" first and next to use "vncviewer localhost:5901" to connect VNC viewer, nevertheless it still show this error "Can't open display:".

                 

                Last login: Thu Sep 13 13:00:42 2018 from gateway
                [root@Oracle18c ~]# ssh -L 5901:localhost:5995 vnc-89D@192.168.210.10
                vnc-89D@192.168.210.10's password: 
                Last login: Thu Sep 13 13:02:33 2018 from oracle18c
                [vnc-89D@Oracle18c ~]$ 
                [vnc-89D@Oracle18c ~]$ vncviewer localhost:5901
                
                
                TigerVNC Viewer 64-bit v1.8.0
                Built on: 2018-04-11 19:46
                Copyright (C) 1999-2017 TigerVNC Team and many others (see README.txt)
                See http://www.tigervnc.org for information on TigerVNC.
                Can't open display: 
                [vnc-89D@Oracle18c ~]$ 
                

                 

                Only on root user it's normal that I can use this command "vncviewer localhost:5995 or 95" to connect to VNC server (because the prior to the first post I haven't chosen to "Forward X11....." on "Session Options" on my SecureCRT client, although I run the "Xmanager - Passive" on the taskbar).

                 

                1.png

                 

                2.png

                 

                3.png

                 

                4.png

                 

                BTW If I remove this parameter "-localhost" on configuration file "/etc/systemd/system/vncserver\@\:95.service" and I could use the VNC Viewer to manually input "192.168.210.10:5995" to connect it.

                 

                [root@Oracle18c ~]# cat /etc/systemd/system/vncserver\@\:95.service 
                # The vncserver service unit file
                #
                # Quick HowTo:
                # 1. Copy this file to /etc/systemd/system/vncserver@.service
                # 2. Replace <USER> with the actual user name and edit vncserver
                #    parameters appropriately
                #    (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
                #     PIDFile=/home/<USER>/.vnc/%H%i.pid)
                # 3. Run `systemctl daemon-reload`
                # 4. Run `systemctl enable vncserver@:<display>.service`
                
                
                ......
                
                
                # Clean any existing files in /tmp/.X11-unix environment
                ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
                ExecStart=/usr/sbin/runuser -l vnc-89D -c "/usr/bin/vncserver %i -alwaysshared -depth 16 -geometry 1280x800 -SecurityTypes=vncauth"
                PIDFile=/home/vnc-89D/.vnc/%H%i.pid
                ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
                

                 

                [root@Oracle18c ~]# vncpilot -r
                VNCpilot 1.0. Copyright (c) 2018 Dude! @ Oracle Community.
                Free under the GNU General Public License. See vncpilot --help for info.
                
                
                 VNC service:         vncserver@:95.service
                 Username:            vnc-89D
                
                
                 WARNING: All corresponding VNC client connections and processes
                          will be aborted.
                
                
                 Are you sure you want to reload the VNC service?
                
                
                Enter (Y)es or (N)o, or (A)bort: [n] Y
                
                
                 Service Summary:
                
                
                 VNC service unit:    /etc/systemd/system/vncserver@:95.service
                 VNC attributes:      alwaysshared, 1280x800x16, localhost, vncauth
                 Service status:      enabled, active
                
                
                       TCP/IP address  | TCP port | Port status 
                       192.168.210.10  |   5995   |  listening
                

                 

                5.png

                6.png

                Best Regards

                Quanwen Zhao

                 

                Update:

                rpm -ivh vncpilot-1.0-1.el7.x86_64.rpm

                Because the vncpilot has been uploaded to Oracle Linux 7.5, there hasn't existed in the original RPM packages of YUM.

                • 6. Re: xhost:  unable to open display ""
                  Quanwen Zhao

                  Dude! wrote:

                   

                  I suggest you do the following as user root:

                   

                  1. run "vncpilot -d"

                  This will complete remove the VNC service.

                   

                  2. run "vncpilot -c"

                  This will setup the VNC service and show you the password.

                   

                  3. Start a VNC client or viewer on your Windows PC desktop and connect it to locahost port 5901. If you need instructions, please see 3.6.2 Microsoft Windows

                   

                  Hello, Dude!

                   

                  How I could use another Port (not the default 5995) when creating VNCpilot's configuration?

                   

                  About how to transfor your source code of VNCpilot to the published RPM format?

                   

                  Best Regards

                  Quanwen Zhao

                  • 7. Re: xhost:  unable to open display ""
                    Nik

                    Hi.

                    According VNCpilot 1.0.1 Source  it's look like port number is hardcoded.

                    You need change g_port=95 to required  Display Number.

                    VNCPort number= 5900 + Display Number.

                     

                     

                    You must start vncvviewr from you windows, not inside ssh session.

                     

                     

                    Regards,

                    Nik.

                    • 8. Re: xhost:  unable to open display ""
                      Dude!

                      BTW If I remove this parameter "-localhost" on configuration file "/etc/systemd/system/vncserver\@\:95.service" and I could use the VNC Viewer to manually input "192.168.210.10:5995" to connect it.

                       

                      Please do not remove -localhost. It defeats the whole purpose and VNC security. There is no need for Xmanager and you do NOT connect your VNC session to port 5995. There is no need to modify the systemd VNC service and you also do not use X11 forwarding or need Xhost, etc. What are you trying to accomplish?

                       

                      Did you watch the 4 minute demo? Please follow the instructions.

                       

                      The concept is very simple.

                       

                      At your PC, establish as SSH tunnel to your Linux server as instructed.

                      This is only to create a ssh tunnel - you don't use this connection for anything else.

                       

                      Then open vncviewer from your PC and connnect to localhost:5901

                      Because of the tunnel, the VNC connection to port 5901 on your localhost will appear on your Linux server as a local connection to port 5995.

                       

                      It's exactly as described. What is so difficult to understand?

                      • 9. Re: xhost:  unable to open display ""
                        Dude!

                        [vnc-89D@Oracle18c ~]$ vncviewer localhost:5901 

                        Where did you see or read to open the vncviewer from an SSH connection?

                        Most likely, a vncviewer on your remote Linux server doesn't even exist because it requires X window.

                         

                        The purpose of using VNC is that you do not use X11 forwarding and do not need to install X on your Linux server.

                         

                        Update:

                        rpm -ivh vncpilot-1.0-1.el7.x86_64.rpm

                        Because the vncpilot has been uploaded to Oracle Linux 7.5, there hasn't existed in the original RPM packages of YUM.

                         

                        Original RPM packages of yum?

                         

                        YUM is a front-end for rpm which automatically resolves software dependencies. These dependencies are defined in the rpm package. Simply use yum install ncpilot-1.0-1.el7.x86_64.rpm as outlined. If yum does not find a package in the configured repository, it will automatically search the local file directory.

                         

                        Sorry, but all the trouble and concerns you have are unnecessary and happening because you do not understand or follow the instructions. Doesn't it occur to you that you might be doing something fundamentally wrong when something does not work as outlined? Maybe I will change the vncpilot summary to make it more clear to open the vncviewer from you PC and not the ssh session, but unfortunately there is a 24 lines limit so I cannot add a lot of info. However, the 4 minute demo and screenshots in the instructions for MS Windows demonstrate that you open the VNC viewer from your PC desktop, not within the SSH session.

                        • 10. Re: xhost:  unable to open display ""
                          Sreek-Oracle

                          Greetings Zhao,

                          Not sure if this helps -

                          Oracle External KM Doc  How to configure, manage and secure user access to the Linux X server (Doc ID 459029.1)

                           

                          • 11. Re: xhost:  unable to open display ""
                            Dude!

                            The document is about X11 forwarding. It requires that X Window is installed on the local PC system. The purpose of VNC and vncpilot, however is to avoid the installation of X Window and X11 forwarding.

                             

                            The reason for all at trouble is simply because the OP opened a VNC session at the remote system using the SSH connection, instead of using a VNC viewer on the PC desktop and connecting to localhost port 5901.

                            • 12. Re: xhost:  unable to open display ""
                              Dude!

                              I decided to change the vncpilot summary screen for better understanding. This will hopefully make it clear to start the VNC viewer from your PC Desktop and not through the remote SSH connection. Although this should be clear according to the installation instructions and video demo, this will hopefully help to avoid such issues in the future. Thanks for the feedback!

                               

                              Simply download the package from VNCpilot for OL/EL 7 and use yum to update it:

                               

                              $ yum install vncpilot-1.0.1-1.el7.x86_64.rpm

                               

                              This will either update or install the downloaded vncpilot rpm package, including software dependencies if necessary.

                               

                              Screen Shot 2018-09-13 at 4.37.22 PM.jpg

                               

                              To remove remove the VNC service when no longer needed:

                               

                              Screen Shot 2018-09-13 at 4.37.09 PM.jpg

                               

                              Again, you start the VNC viewer or client on the PC Desktop and connect it to localhost:5901

                               

                              There is no need to install X Window or do anything SSH in regard to X11, or xhost, etc. VNC is not using X11 forwarding.

                               

                              If you want to understand more about it:

                              X Window Remote Access Concepts

                              • 13. Re: xhost:  unable to open display ""
                                Quanwen Zhao

                                Please do not remove -localhost. It defeats the whole purpose and VNC security. There is no need for Xmanager and you do NOT connect your VNC session to port 5995. There is no need to modify the systemd VNC service and you also do not use X11 forwarding or need Xhost, etc. What are you trying to accomplish?

                                 

                                Afterwards I added the "-localhost" to the original configuration file and reload VNCpilot.

                                 

                                Did you watch the 4 minute demo? Please follow the instructions.

                                 

                                Just now I watched that simply DEMO via YouTube, according to your suggestion I also type some instruction as follows,

                                 

                                (1) Creating VNC Service,

                                 

                                [root@Oracle18c ~]# vncpilot --create -shared -size=1280x800
                                VNCpilot 1.0. Copyright (c) 2018 Dude! @ Oracle Community.
                                Free under the GNU General Public License. See vncpilot --help for info.
                                
                                
                                 Service Summary:
                                
                                
                                 VNC service unit:    /etc/systemd/system/vncserver@:95.service
                                 VNC attributes:      alwaysshared, 1280x800x16, localhost, vncauth
                                 Service status:      enabled, active
                                
                                
                                 TCP/IP address  | TCP port | Port status | Username | Password
                                 192.168.210.10  |   5995   |  listening  | vnc-89D  | 6HN-jNl-li6
                                
                                
                                
                                
                                  Note:  1. Use SSH on a PC running the VNC viewer to forward a local TCP
                                            port (5901) to the remote TCP port of the VNC service (5995):  
                                            $ ssh -L 5901:localhost:5995 vnc-89D@192.168.210.10
                                
                                
                                         2. Connect the VNC viewer to localhost (127.0.0.1):
                                            $ vncviewer localhost:5901
                                
                                
                                 For help: <https://community.oracle.com/docs/DOC-1024831>
                                

                                 

                                (2) Checking the status of VNCpilot,

                                 

                                [root@Oracle18c ~]# vncpilot -s
                                VNCpilot 1.0. Copyright (c) 2018 Dude! @ Oracle Community.
                                Free under the GNU General Public License. See vncpilot --help for info.
                                
                                
                                 Service Summary:
                                
                                
                                 VNC service unit:    /etc/systemd/system/vncserver@:95.service
                                 VNC attributes:      alwaysshared, 1280x800x16, localhost, vncauth
                                 Service status:      enabled, active
                                
                                
                                       TCP/IP address  | TCP port | Port status | Username
                                       192.168.210.10  |   5995   |  listening  | vnc-89D
                                

                                 

                                (3) Establishing the SSH Tunnel,

                                 

                                [root@Oracle18c ~]# ssh -L 5901:localhost:5995 vnc-89D@192.168.210.10
                                vnc-89D@192.168.210.10's password: 
                                [vnc-89D@Oracle18c ~]$ 
                                

                                 

                                (4) On my PC (Windows 10), using "VNC Viewer" to connect to the virtual desktop on my Oracle Linux 7.5,

                                 

                                1.png

                                2.png

                                3.png

                                So, that's why?

                                 

                                Best Regards

                                Quanwen Zhao

                                • 14. Re: xhost:  unable to open display ""
                                  Nik

                                  Hi.

                                  Mistake on step 3.

                                  You should initiate ssh session from you PC to Linux.

                                  You  create session from Linux to Linux, so  port 5901 was listen on Linux, not on PC.

                                   

                                  You can use any ssh client on your PC.  For example: putty  (   https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html  )

                                   

                                  It can be running with same options as ssh or you can configure session with required options.

                                   

                                   

                                  Regards,

                                  Nik

                                  1 位用户发现它有用
                                  1 2 上一个 下一个