LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Not able to open display of remote server if client is user and server is root (https://www.linuxquestions.org/questions/linux-newbie-8/not-able-to-open-display-of-remote-server-if-client-is-user-and-server-is-root-4175468584/)

unclesamcrazy 07-05-2013 07:50 AM

Not able to open display of remote server if client is user and server is root
 
I am a user.
I log into remote server as a root using ssh -X.
But I am not able to open display of server on my system. It gives following error.
Code:

WARNING **: Unable to start: Cannot open display:
But the twist is here.

If I log in to my system as root.
Now I log into remote server as a root using ssh -X.
I can open display of the server.

But I can't log into my system as a root always.I have to solve the issue and I have to open the remote server's display on my system as a user.

Please help me.

Thanks.

shivaa 07-05-2013 08:01 AM

Did you check that X-forwarding is enabled for your user? This can be done by adding "ForwardX11 yes" to your $HOME/.ssh/config, as:
Code:

~$ echo "ForwardX11 yes" >> $HOME/.ssh/config
Also once invoke following cmd to allow the remote machine to use your X-display:
Code:

~$ xhost +<remote_machine_hostname>
OR
~$ xhost +<remote_machine_ip>


unclesamcrazy 07-06-2013 05:46 AM

Thanks Shivaa for your instant reply.

As I followed your process but I am still facing problem.

Should I run these command on the specifically on the remote host or I can run this on remote host as a root log in through my system.

because if I log in to remote host as a root from my system and run this command
$ xhost +192.168.2.16
It says could not open display.

Should I write remote host IP after xhost + or the IP of the client system.

I am little confused.

Please help.

shivaa 07-06-2013 07:34 AM

Login into your local system and invoke these comanands on local machine itself, and then connect to remote machine and try to import remote machine display on your local machine.
Code:

user@localmachine~$ echo "ForwardX11 yes" >> $HOME/.ssh/config
AND
user@localmachine~$ xhost +<remote_machine_hostname>
OR
user@localmachine~$ xhost +<remote_machine_ip>


unclesamcrazy 07-06-2013 08:25 AM

First i have run this command as a user.
Quote:

user@L177WSB:~$ echo "ForwardX11 yes" >> $HOME/.ssh/config
user@L177WSB:~$
Now if I run these commands on my system as a user, it shows following output.
Quote:

user@L177WSB:~$ xhost
xhost: unable to open display ""
user@L177WSB:~$ xhost +192.168.x.xx
xhost: unable to open display ""
But if I run same command on my system as a root, it shows follwoing output.
Quote:

root@L177WSB:~# xhost
access control enabled, only authorized clients can connect
SI:localuser:root
root@L177WSB:~# xhost +192.168.x.xx
192.168.x.xx being added to access control list

unclesamcrazy 07-09-2013 01:08 AM

I am still facing same problem, please help me.
I am explaining my problem again in short so anyone will not have to read all posts.
I log into my system as a user and log into server as a root using ssh -X. Now I try to open display of the server on my system but it says.
Code:

WARNING **: Could not open X display
 WARNING **: Unable to start: Cannot open display:

But If I log into my system as a root now I log into server as a root using ssh -X. Now I can open display of the server on my system.
I can't log into my system as a root. I have tried above all solutions but I am still facing problem.
Please help me to open display of the server on my system as a user.
Any help would be grately appriciated.
Thanks again.

karim.ouda 07-09-2013 01:37 AM

Have you exported DISPLAY variable? Try to execute this command on your localhost terminal. localhost terminal means When you log in to as user, then only run this command before log into server as a root.
Code:

username@hostname:~$ export DISPLAY='your-IP:0.0'
Now log into the server as a root and try to access it's display.

shivaa 07-09-2013 01:42 AM

What kind of your system is? Is it any particular type of server? And which desktop environment you're using (gnmoe/kde/xfce etc)? However, once login into your local system as normal user as well root both and invoke following command to check whether your DISPLAY varialbe is set properly or not.
Code:

user@localmachine~$ echo $DISPLAY
root@localmachine~# echo $DISPLAY


unclesamcrazy 07-09-2013 02:18 AM

Thanks for your replies.
@Karim - I have tried your command, it says
Code:

** WARNING **: Could not open X display
connect 192.168.xx.xx port 6000: Connection refused
connect 192.168.xx.xx port 6000: Connection refused

** WARNING **: Unable to start: Cannot open display:

@Shivaa -
echo $DISPLAY - For root, it is blank
Code:

[root@L177WSB ~]# echo $DISPLAY

[root@L177WSB ~]#

echo $DISPLAY - For user, it is 192.168.xx.xx:0.0 (I think it is because I executed Karim's command, I do not know what was it before)
Code:

user@L177WSB:~$ echo $DISPLAY
192.168.xx.xx:0.0


karim.ouda 07-09-2013 02:25 AM

Output is blank for root and still you are able to access display successfully & :0.0 is set for user and still you are not able to access user.

I do not know but how can it be possible. Theoretically, it should not be happened.

I have tried on my system right now and set blank variable using
Quote:

export DISPLAY=''
and I am not able to access display.

I am not sure but are you sure about your details.:scratch:

unclesamcrazy 07-09-2013 02:57 AM

I do not know why experts don't believe me, this is my third thread where this is happening.:o

http://www.linuxquestions.org/questi...-c-4175463567/
http://www.linuxquestions.org/questi...ly-4175465964/

I had put screen-shot but still no one believed me. :(
Both problems are still unsolved. Since it is not a support forum, it is a volunteer forum. members help if they can or if they want to, that's why I left the issue for now but one day I will create new thread again. I hope some one will not point out that "You have asked this question __ years/months before and you are still facing same problem" :(

But you both have given your precious time, what can I ask more from you.

I am really grateful.

karim.ouda 07-09-2013 03:17 AM

First thing I am not an expert, see my status, I am a newbie but yes, Shivaa is an expert and he is not the one who is not believing you, I wrote that.
Even you have more posts than mine and chronologically you are senior too. I had one more account here in which I had more than 225 posts and 50+ reputation but a member started Persecuting me. What I posted he criticized badly that's why I had to leave the account and I have created new one. Now he doesn't follow me anymore.

but we are not discussing my problem, the thread is yours. I was not saying I am not believing you but what you are saying it doesn't look correct.

Ok, try to execute these commands.
Code:

username@hostname:~$ export DISPLAY='127.0.0.1:0.0'
username@hostname:~$ export DISPLAY='localhost:0.0'

and try again.

shivaa 07-09-2013 04:15 AM

I had come accross this issue hundred of times during my work on VNC servers. There is no trick as such I know, but I guess somewhere something is missing from your side. However, once try as follow:
Login into your local system using normal user and invoke:
Code:

user@localmachine~$ xhost +
Then login into remote machine as root/normal user, and invoke:
Code:

root@lremotemachine~# export DISPLAY='192.168.xx.xx:0.0'
root@lremotemachine~# xclock &
OR
root@lremotemachine~# xterm &

If you still get the display error on remote machine, then while setting display (i.e. export DISPLAY='192.168.xx.xx:0.0') use fully qualified domain name of the local machine instead of it's IP address, i.e.
Code:

root@remotemachine~# export DISPLAY='localmachine.abc.org.com:0.0'

TB0ne 07-13-2013 02:09 PM

Quote:

Originally Posted by unclesamcrazy (Post 4984643)
I am a user.
I log into remote server as a root using ssh -X. But I am not able to open display of server on my system. It gives following error.
Code:

WARNING **: Unable to start: Cannot open display:
But the twist is here.

If I log in to my system as root. Now I log into remote server as a root using ssh -X. I can open display of the server. But I can't log into my system as a root always.I have to solve the issue and I have to open the remote server's display on my system as a user.

Interestingly enough, it's probably because of the different user ID's, and the different .Xauthority files. You can try running
Code:

xauth add "$(/bin/hostname)/unix:0" MIT-MAGIC-COOKIE-1 $( xauth list "localhost/unix:0" | awk '{print $3}' )
...as your 'regular' user and see what it does. You may have to reboot your local workstation afterwards, since sometimes just restarting X isn't enough for things to work (even though it should be). Another good question is how are you starting X windows on your local workstation? Is it running at boot time, or are you using "startx"? Because just the "xhost +" should work, if you're starting X as your 'regular' user, but will NOT work if you're starting that X session as root.

The first thing is don't log in to ANYTHING as root. Log in as your regular user on your local system, and log in as the SAME user ID on the remote system, then run whatever command you want with "sudo <command name>". Logging in as root is always dangerous. See section 7 of this document for a better explanation of the .Xauthority file(s), and why doing remote X sessions as different users is difficult:
http://www.faqs.org/docs/Linux-mini/...X-Apps.html#s7

A short version of things, some of which you seem to have done already:
  • Log in to your local workstation as your regular user ID.
  • Run "xhost +" or "xhost <ip address of remote server>".
  • SSH to the remote server as your regular user ID.
  • Assuming you're using BASH, run "export DISPLAY=<ip address of your local workstation>:0"
  • Run "sudo <command name of whatever X application you want to run>".
Sudo will start the application with root privileges, but inherit the other rights it needs. It SHOULD work. But, you don't say what version/distro of Linux you're using for either your remote or local system, or what application(s) you're trying to run. Some apps (like Java apps, for instance), may have problems no matter what, but 'regular' apps work fine.

Quote:

Originally Posted by karim.ouda
Even you have more posts than mine and chronologically you are senior too. I had one more account here in which I had more than 225 posts and 50+ reputation but a member started Persecuting me. What I posted he criticized badly that's why I had to leave the account and I have created new one. Now he doesn't follow me anymore.

Sorry, this isn't correct at all, and if you feel that you are 'persecuted' because someone corrected you after you posted wrong/misleading information in threads they subscribed to, that's your problem.

karim.ouda 07-19-2013 08:23 AM

Quote:

Originally Posted by TB0ne (Post 4989754)
Sorry, this isn't correct at all, and if you feel that you are 'persecuted' because someone corrected you after you posted wrong/misleading information in threads they subscribed to, that's your problem.

No TB0ne, you don't know him. That motherboard-baskit is worse than floddy gimp. Every one here is not like you, a real gentleman.
He is nothing but a CowArt spiene-less Euunuchh who always stabs in back. Don't worry about him. I will take care of that sun of sut.
You are a real diamond man. Your posts are really helpful.
I am not going to take his name but the a-whole always says two things.'
Spell Out your words'
&
No Idea what you are talking about.
May be you encountered him many times.
well leave it, you are a gem man, keep helping others.
cháo


All times are GMT -5. The time now is 02:57 AM.