How to enable X11 forwarding from Red Hat Enterprise …
https://aws.amazon.com/blogs/compute/how-to-enable-x11-forwarding-from-red-hat-enterprise-linux-rhel-amazon-linux-suse-linux-ubuntu-server-to-support-gui-based-installations-from-amazon-ec2/
Step 1: Install required X11 packages Step 1: Install required X11 packages Install X11 packages with following command based on your operating system release and version: Installing xclock or xterm packages are optional as this is installed in this post to test the X11 forwarding using xclock or xterm commands. Amazon Linux 2: To install X11 related packages: $ sudo yum install xorg-x11-xauth To install X11 testing tools: $ sudo yum install xclock xterm Red Hat Enterprise Linux 8: To install X11 related packages: $ sudo yum install xorg-x11-xauth To install X11 testing tools: $ sudo yum install xterm Note: The xorg-x11-apps package has been provided in the for RHEL8. So, I skipped installing this package, which has xclock and I used only xterm to test the X11 forwarding. SUSE Linux Enterprise Server 15 SP1: To install X11 related packages: $ sudo zypper install xauth To install X11 testing tools: $ sudo zypper install xclock Ubuntu Server 18: To install X11 related packages and tools: $ sudo apt install x11-appsStep 2: configure X11 forwarding Step 2: configure X11 forwarding To enable X11 Forwarding, change the “X11Forwarding” parameter using vi editor to “yes” in the /etc/ssh/sshd_config file if either commented out or set to no. $ sudo vi /etc/ssh/sshd_config To Verify X11Forwarding parameter: $ sudo cat /etc/ssh/sshd_config |grep -i X11Forwarding You should see similar output as the following: X11Forwarding yes To restart ssh service if you changed the value in /etc/ssh/sshd_config: Amazon Linux 2, RHEL 8 and SUSE Linux OS: $ sudo service sshd restart Ubuntu Servers: $ sudo service ssh restart Step 3: Configure putty and Xming to perform X11 forwarding connect and verify X11 forwarding Step 3: Configure putty and Xming to perform X11 forwarding connect and verify X11 forwarding Log in to your Windows bastion host. Then, open a fresh PuTTY session, and use a private key or password-based authentication per your organization setup. Then, test the xclock or xterm command to see x11 forwarding in action. Click the xming utility you installed on Windows bastion host and have it running. Select Session from the Category pane on left. Set Host Name as your private IP, port 22, and Connection Type as SSH. Please note that you use the Private IP of EC2 instance later when you connect inside from the VPC/network. Go to Connection, and click Then, set Auto-login username as ec2-user, Ubuntu (Ubuntu OS), or whichever user you are allowed to logging in as. Go to Connection, select SSH, and then click Then, click on Browse to select the private key generated earlier If you are using key based authentication. Go to Connection, select SSH, and then click on Then, select enable X11 forwarding. Set X display location as localhost:0.0 Go back to Session and click on Save after creating a session name in Saved session. Now that you set up PuTTY, xming, and configured the x11 settings, you can click on load button and then Open button. This opens up a new SSH terminal with x11 forwarding enabled. Now, I move on to the testing X11 forwarding. Test the X11 from the use you logged in: Example: $ xauth list $ export DISPLAY=localhost:10.0 $ xclock or xterm You should see the sample output and xclock or xterm window opened similar to the following image. This means your x11 forwarding setup working as expected, and you can start using GUI-based application installation or configuration by running the installer or configuration tools.Step 4: Configure the EC2 Linux session to forward X11 if you are switching to different user after login to run GUI-based installation / commands Step 4: Configure the EC2 Linux session to forward X11 if you are switching to different user after login to run GUI-based installation / commands In this example: ec2-user is the user logged in with SSH and then switched to oracle user. From the Logged User to identify the xauth details: $ xauth list $ env|grep DISPLAY $ xauth list | grep unix`echo $DISPLAY | cut -c10-12` > /tmp/xauth Switch to the user where you want to run GUI-based installation or tools: $ sudo su - oracle $ xauth add `cat /tmp/xauth` $ xauth list $ env|grep DISPLAY $ export DISPLAY=localhost:10.0 $ xclock You should see the sample output and xclock or xterm window opened similar to the following image. This means your x11 forwarding setup is working as expected even after switched to different user. You can start using GUI-based application such as running the installer or configuration tools. Conclusion In this blog, I demonstrated how to configure instances running on various linux-based operating systems to forward X11 to the Windows OS-based bastion host. This is helpful to any application installation that requires GUI-based installation methods. This is also helpful to any bastion hosts that provide highly secure and low latency environments to perform SSH related operations including GUI-based installations as this does not require any additional network configuration other than opening the port 22 for standard SSH authentication. Please try this tutorial for yourself, and leave any comments following! TAGS: , , , ,
DA: 79 PA: 89 MOZ Rank: 100