Amazon Web Services Tips |
Remote Desktop to an Amazon EC2 Instance
by Jeff Hunter, Sr. Database Administrator
In most cases, the Linux servers I setup as Amazon EC2 instances are used to host the Oracle database software and only require use of the operating system Command-Line Interface (CLI). This is beneficial because I only need register an Amazon Machine Image (AMI) with a Minimal or Basic Server OS installation and can add only those required Linux packages needed to support the database. However, there are situations where I need to access a graphical desktop in order to install or run certain Graphical User Interface (GUI) applications.
This guide provides the steps needed to add the GNOME Desktop to a Red Hat Enterprise Linux 6.2 AMI where the OS was installed without the X Window System. Although there are several options to enable a remote desktop on an EC2 instance, I prefer to use NX Free Edition (FreeNX).
FreeNX is a program which allows users to run remote X11 sessions from clients running on Windows, Linux, Mac OS X and Solaris platforms to servers running, at present, on Linux or Solaris.
This guide assumes you have an Amazon Web Services account and know how to create new EC2 instances from an AMI, key-pairs and security groups within the AWS Management Console.
The Red Hat Enterprise Linux 6.2 AMI, like most community AMIs, does not include the GNOME Desktop or X Window System software. In this section, the required GUI packages will be installed to the running instance using yum.
|
You can also install the following optional GUI packages.
|
Finally, if you wanted to add the K Desktop Environment (KDE).
|
When using yum groupinstall, the groupinstall option only installs default and mandatory packages from the group. There are times when you also want to include optional packages within a group. I have not figured out (yet) how to control which package types to install (group package "policy") from the command-line using yum. The only method I know of to also include optional packages is to edit the /etc/yum.conf file and add the following to the [main] section:
|
The reason I mention this is because I wanted to install "Terminal emulator for the X Window System" (xterm) which is under the group "Legacy X Window System compatibility". xterm happens to be an optional package and did not get installed until I added group_package_types=default mandatory optional to /etc/yum.conf.
|
I did find a plug-in for yum that allows users to specify which package types within a package group should be installed when using yum groupinstall.
http://projects.robinbowes.com/yum-grouppackagetypes/trac
Since the server was previously running on CLI mode, we need to change the initialization process for the machine to boot up in GUI mode.
Open /etc/inittab using a text editor and change following line:
|
To:
|
After making the change, reboot the machine.
|
In this section, NX Free Edition for Linux - x86_64 will be installed on the EC2 instance.
Note that the installation instructions for Red Hat Enterprise Linux (RHEL) and CentOS are not the same.
Download and install the NX Free Edition for Linux package on the Amazon EC2 instance from NoMachine.
|
The NX service can be controlled by the command /usr/NX/bin/nxserver --status|--start|--stop|--restart. For example,
|
Additional commands are available to configure the server. Try /usr/NX/bin/nxserver --help for more options. To learn more, download and read the NX Server Administrator's Guide.
Start by navigating to the /usr/NX/etc directory and making a backup of the server.cfg file.
|
Edit the server.cfg file to enable EnablePasswordDB = "1".
|
Modify the /etc/ssh/sshd_config file and make sure the following entries are set.
|
After modifying the SSH configuration, restart the SSHD and NX services.
|
Setup SSH key.
|
Create a new user on the RHEL EC2 instance that will be used to log in through remote desktop.
|
Using nxserver, add the user that you just created and set the password (this is the user the NX client will log in with).
|
When using CentOS, a version of FreeNX is available from the CentOS Extras repository which is typically shipped with CentOS and enabled by default. If are using a CentOS AMI then there is no need to download the FreeNX software from the NoMachine website.
|
Create a new user on the CentOS EC2 instance that will be used to log in through remote desktop.
Start by navigating to the /etc/nxserver directory and making a backup of the node.conf file.
|
Edit the node.conf file to enable ENABLE_PASSDB_AUTHENTICATION="1".
|
Modify the /etc/ssh/sshd_config file and sure the following entries are set.
|
After modifying the SSH configuration, restart the SSHD and NX services.
|
Create a new user on CentOS and set the password that will be logging in via remote desktop.
|
Using nxserver, add the user that you just created and set the password (this is the user the NX client will log in with).
|
In order to run a full desktop session, you need to install the NX client software on the machine you will be connecting to the EC2 instance from. Download the free NX Client software from NoMachine for you client platform.
|
|
|
|
Figure 1: NX Client for Windows - Welcome Screen
|
|
|
|
|
Figure 2: NX Client for Windows - Select Destination Location
|
|
|
|
|
Figure 3: NX Client for Windows - Select Start Menu Folder
|
|
|
|
|
Figure 4: NX Client for Windows - Select Additional Tasks
|
|
|
|
|
Figure 5: NX Client for Windows - Ready to Install
|
|
|
|
|
Figure 6: NX Client for Windows - Installation Complete
|
|
To setup a new remote desktop connection from the client machine, start the NX Connection Wizard using Start > All Programs > NX Client for Windows > NX Connection Wizard.
|
|
|
Figure 7: NX Connection Wizard - Welcome Screen
|
|
Fill in the values as shown below. Make sure that you put in your server address in the host field which is the address of your launched instance.
|
|
|
Figure 8: NX Connection Wizard - Session Name
|
|
Provide the desktop type appropriate for your environment (i.e. GNOME).
|
|
|
Figure 9: NX Connection Wizard - Select Remote Desktop
|
|
Click [Finish] to complete the wizard.
|
|
|
Figure 10: NX Connection Wizard - Wizard Completed
|
|
In order for freeNX to function securely we need to copy the ssh key from the remote server system to the local machines NoMachine client session.
Log in to the EC2 instance using a terminal session and display the SSH key.
|
Open the NX Client for Windows software using Start > All Programs > NX Client for Windows > NX Client for Windows. Select the correct session in the Session pull-down and click the [Configure] button.
|
|
|
Figure 11: NX Client - Edit Session
|
|
Under the General tab, click the [Key] button. Clear the previous contents and Paste the contents from the remote system /var/lib/nxserver/home/.ssh/client.id_dsa.key.
|
|
|
Figure 12: NX Client - Paste SSH Key
|
|
Log in to the EC2 instance using the NX Client.
|
|
|
Figure 13: NX Client - Login Dialog
|
|
You should now be able to access the GNOME remote desktop.
If you want to switch back from a full screen session to your native OS desktop, you can click on the 'magic pixel' on the upper right edge of your screen.
Ctrl + Alt + Shift + Esc to get rid of a not responding session
Ctrl + Alt + T to terminate a session
Ctrl + Alt + F to switch to full screen/windowed (Note: This feature is not available on Windows)
Ctrl + Alt + Shift + F to switch to multi-monitor full screen/windowed (Note: This feature is not available on Windows)
Ctrl + Alt + M to minimize or maximize full screen window
Ctrl + Alt + arrow keys to view-port navigation
Ctrl + Alt + keypad arrow keys to view-port navigation (Note: this action is performed also by keeping Ctrl + Alt pressed and dragging the content of the main window by the pointer)
Ctrl + Alt + R to switch "auto-resize/view-port" mode. The agent starts in auto-resize mode, so users can resize the desktop simply by resizing the main window. In view-port mode, resizing the main window doesn't make the desktop resize itself, but users can navigate the desktop by moving the view-port (Note: the auto-resize feature will be available on Windows starting with NX 4.0.0)
Ctrl + Alt + E to toggle the lazy encoding
Ctrl + Alt + J to force a drawable synchronization, in order to attempt a fix for a visualization problem
Alt + F4 when the window manager is present, it allows you to suspend or terminate a session
Ctrl + Alt + K enable/disable the catching of Alt+Tab and Print Screen keys
Jeffrey Hunter is an Oracle Certified Professional, Java Development Certified Professional, Author, and an Oracle ACE. Jeff currently works as a Senior Database Administrator for The DBA Zone, Inc. located in Pittsburgh, Pennsylvania. His work includes advanced performance tuning, Java and PL/SQL programming, developing high availability solutions, capacity planning, database security, and physical / logical database design in a UNIX, Linux, and Windows server environment. Jeff's other interests include mathematical encryption theory, programming language processors (compilers and interpreters) in Java and C, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. Database Administrator and Software Engineer for over 18 years and maintains his own website site at: http://www.iDevelopment.info. Jeff graduated from Stanislaus State University in Turlock, California, with a Bachelor's degree in Computer Science.
Copyright (c) 1998-2013 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
Last modified on
Friday, 29-Mar-2013 14:33:50 EDT
Page Count: 10859