u915

Daniel Cano Merchán - Hacking & Tech

ssh X11 forwarding Oracle Linux 7 RHEL OCI

2021-01-10 #Fix #Linux #OCI

This post is about how to enable ssh X11 forwarding on Oracle Linux 7 OCI (Oracle Cloud Infrastructure)

Tested with the following version in a fresh instance:

Linux linux 5.4.17-2036.100.6.1.el7uek.x86_64 #2 SMP Thu Oct 29 17:04:48 PDT 2020 x86_64 x86_64 x86_64 GNU/Linux 

Common error

X11 forwarding request failed on channel 0

I got this error when I sucessfully login to the Linux instance via SSH.

Packages needed

sudo yum install -y xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-apps

-y to accept the install xorg-x11-server-Xorg in case is not installed xorg-x11-xauth to enable X authentication and finally xorg-x11-apps to test X11 with dummy apps

Modify sshd_config

Root permissions required. Use your favorite text editor to edit the following file:

sudo vim /etc/ssh/sshd_config

Add/modify

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no

Reload the new SSH configuration

Reload the service to enable the changes made

sudo systemctl reload sshd.service

Test your instance

Don´t forget to use the flag -X or -Y to enable X11 forwarding when connecting to the Linux instance:

ssh -X user@ip

If you are using your key:

ssh -X -i "path_to_key.key" user@ip

Plus, you can enable the debug mode with the flag -v if you still have issues:

ssh -X -v -i "path_to_key.key" user@ip

When you sucessfully connect with the Linux instance you will see the following lines:

debug1: Requesting X11 forwarding with authentication spoofing.
debug1: Requesting authentication agent forwarding.

If all went as expected you can launch graphical apps like the venerable Xeyes

alt text

Thanks for reading!