Technical Articles
Using X Forwarding on SAP Cloud Platform Virtual Machines
Not all applications have command line interfaces. At least for their installation or configuration you may need a graphical interface. To avoid installing a full featured graphical desktop on your Linux virtual machine you can use a feature called X forwarding. It will allow you to have all the needed graphical features, which might be necessary for your application.
In this particular scenario for Windows OS, you are going to connect to a SAP Cloud Platform virtual machine by using the PuTTY SSH client instead of using the SSH client from the SDK tools folder. By enabling the PuTTY X11 forwarding option, you are going to install and run a sample X application on your virtual machine.
Prerequisites
Before you proceed with the scenario, let’s take a look at what software you are going to need in advance:
- Set up the PuTTY SSH client.
- As part of the PuTTY package, you should also have the PuTTYgen key generator and Pageant at your disposal.
- Install Xming and start it before proceeding to the preliminary steps. Xming should be running while performing the preliminary and main steps.
Preliminary Steps
- First, open an SSH tunnel. The SSH tunnel will be available on a specific port (for example, on port 57673).
- You need to convert the selected .key file for this scenario to a .ppk file.
To convert a previously generated .key file to a .ppk file, use the following steps:
1. Open PuTTYgen.
2. Select Load → All Files. Find the folder where your .key file is stored.
Note: If you don’t have an available .key file for some reason, you can create a new one using PuTTYgen.
3. Select the .key file of your choice. That’s .key file that has to be converted to a .ppk key.
4. Choose Open.
5. Finally, save it as a private key. In this scenario, you don’t have to use a passphrase.
Note: The converted key file should have the .ppk extension!
Main Steps
1. Open Pageant.
2. Select Add Key and open the .ppk file.
3. Open the PuTTY SSH client and start a PuTTY session.
Type localhost in the “Host Name (or IP address)” field and the port number in the “Port” field. In the “Port” field type the port on which the SSH tunnel is opened (for example, port 57673).
Then, choose Open to connect to the virtual machine. Choose “Yes” if prompted, log in as root, and press enter.
4. Gain access to the SUSE Linux Enterprise Server (SLES) repositories.
You need access to the SLES repositories. These repositories are storage locations from which you can retrieve and install software packages on the virtual machine. To configure your access to them, execute the following commands in the PuTTY SSH client console with the respective region host where your virtual machine is running:
zypper addrepo -f https://slesrepo.hana.ondemand.com/repo/SUSE/Products/SLE-SERVER/12-SP1/x86_64/product/ SUSE12SP1
zypper addrepo -f https://slesrepo.hana.ondemand.com/repo/SUSE/Products/SLE-SDK/12-SP1/x86_64/product/ SUSE12SP1SDK
zypper addrepo -f https://slesrepo.hana.ondemand.com/repo/SUSE/Updates/SLE-SERVER/12-SP1/x86_64/update/ SUSE12SP1UPDATE
zypper addrepo -f https://slesrepo.hana.ondemand.com/repo/SUSE/Updates/SLE-SERVER/12-SP1-LTSS/x86_64/update/ SUSE12SP1LTSSUPDATE
zypper addrepo -f https://slesrepo.hana.ondemand.com/repo/SUSE/Updates/SLE-SDK/12-SP1/x86_64/update/ SUSE12SP1SDKUPDATE
For more information, see the official SAP Cloud Platform documentation.
Note: If you lose connection for some reason, just open a new SSH tunnel. Everything else stays the same.
5. In addition, install the following two packages:
zypper install xauth xclock
These packages are needed for the purpose of this scenario. However, you are free to install other ones as you see fit.
Tips: During the installation process you are going to be prompted to answer some questions. Proceed as follows:
Q: Do you want to reject the key, trust temporarily, or trust always? (r/t/a?)
A: Type “a” for always.
Q: Continue? (y/n?)
A: Type “y” for yes.
6. Terminate the PuTTY session.
7. Start a new PuTTY session.
Again, type localhost in the “Host Name (or IP address)” field and the port number in the “Port” field. However, this time you also need to go to Connection → SSH → X11. Select the Enable X11 Forwarding option there.
Then, choose Open to connect to the virtual machine. Choose “Yes” if prompted, log in as root, and press enter.
Note: You can enable the X11 forwarding before starting the first PuTTY session, but the scenario won’t work in this case.
8. Type xclock in the PuTTY console client and press enter.
As a result, a clock widget has to appear. If this is the case, then the scenario is successfully completed.
Of course, you can experiment with other widgets and X applications. Feel free to share your experience!
Cool tip! thanks for sharing!
You are welcome! I am glad you liked it!