Ran below commands on MobaXTerm:
Using MobaXTerm terminal on windows laptop:
> xhost +ulv78.abc.com
ulv78.abc.com being added to access control list
> ssh -l someuser ulv78.abc.com # RHEL 7.x
SECURITY NOTICE:
Unauthorized use is prohibited. Use of this private computer system is your consent to being recorded and monitored. We reserve the right to seek all remedies for unauthorized use. Evidence of suspected illegal use may be given to law enforcement.
X11 forwarding request failed on channel 0
Last login: Thu Sep 20 12:06:57 2018 from win_host_name
$ bash
$ echo DISPLAY=win_host_name:0.0; export DISPLAY >> .bashrc
$ sudo su - # as root sudoer
$ echo DISPLAY=win_host_name:0.0; export DISPLAY >> .bashrc
$ cd /install_path
$ ./setup
Error: Can't open display: win_host_name:0.0
Above session has X11 forwarding request failed on channel 0
error
Edit:
Set DISPLAY
entry in .profile
& .bashrc
. As soon as I connect from MobaXterm terminal, below is the output:
> ssh -l someuser ulv78.abc.com
SECURITY NOTICE:
Unauthorized use is prohibited. Use of this private computer system is your consent to being recorded and monitored. We reserve the right to seek all remedies for unauthorized use. Evidence of suspected illegal use may be given to law enforcement.
X11 forwarding request failed on channel 0
Last login: Thu Sep 20 12:36:54 2018 from win_host_name
$ echo $DISPLAY
win_host_name:0.0
$ xterm
xterm: Xt error: Can't open display: win_host_name:0.0
$
1) How to resolve X11 forwarding error?
2) I see wrong domain name showing in the last login msg of ssh client.
Best Answer
X11 forwarding (as the initial user)
MobaXTerm supports X11 forwarding, enabled by default. If X11 forwarding is enabled on the linux server (
ulv78
), thenDISPLAY
is set to an apparently local address, and yourssh
client forwards those requests back to your X11 server (running on your Windows machine). See How to forward X over SSH to run graphics applications remotely? for more details about how this works.When this is setup correctly, you should not change the
DISPLAY
environment variable yourself; if you've added lines to your login files (.bashrc
etc) to set it, you'll have to delete them again. Your should see results like this:(Now running as
user
on remote machine)xterm
is used as a test app here. It should appear on your Windows machine, despite being started by the remote Linux machine. Its prompt will indicate that you areuser@ulv78
, rather than MobaXTerm's initial prompt.Congratulations, that's the first step. X11 forwarding is working. Now on to the advanced part:
Accessing the X11 server as another user
When you switch to another user (such as
root
) viasu -
and try to run graphical applications on the same X server, you'll discover that your environment variables have all disappeared. This is when you do have to changeDISPLAY
manually, as well as copying the X credentials with the xauth(1) command (instructions based on https://blog.mobatek.net/post/how-to-keep-X11-display-after-su-or-sudo/ ):(Now running as
user
on remote machine)(Now running as root)
The
./setup
application will now appear on your Windows machine, just like thexterm
did earlier.