TechTorch

Location:HOME > Technology > content

Technology

How to Install Ubuntu Desktop on an Amazon EC2 Instance

January 16, 2025Technology3815
How to Install Ubuntu Desktop on an Amazon EC2 Instance If youre looki

How to Install Ubuntu Desktop on an Amazon EC2 Instance

If you're looking to deploy a Desktop environment on an AWS EC2 instance, this guide will walk you through the necessary steps. Whether you plan to use VNC or RDP, these instructions will help you set up a functional desktop environment on your instance.

Requirements

To follow this guide, you will need an active AWS account and an EC2 instance. Familiarity with basic Linux commands and administrative tasks on AWS is recommended.

Steps to Install Ubuntu Desktop on EC2

1. SSH into your EC2 instance as root: You can use the command line or AWS Management Console to SSH into your instance. Ensure you have your AWS credentials and the instance's public IP address.

ssh -i  

2. Update and Upgrade Your System: Before proceeding, make sure your system is up-to-date.

apt update -yapt upgrade -y

3. Allow Password Authentication in SSH: You might need to allow password authentication to connect to the desktop environment later.

sed -i s/^PasswordAuthentication no/PasswordAuthentication yes/ /etc/ssh/sshd_config

4. Restart SSH Service:

/etc/init.d/ssh restart

5. Create a New User:

This step will create a new user on your instance.

adduser username

Set a Password: Replace username with your preferred username and set a strong password.

6. Edit the /etc/sudoers file: Add the new user to the sudo group.

visudo

Locate the line for the new user and add the sudo keyword:

username ALL(ALL) NOPASSWD:ALL

7. Install Ubuntu Desktop Environment: Use the following command to install the Ubuntu Desktop environment.

apt install ubuntu-desktop -y

8. Install VNC Server: Ubuntu comes with the TightVNC server pre-installed, so you can install it using the following command.

apt install tightvncserver -y

9. Configure VNC Server: Set up your VNC server for the first time by running the command:

vncserver

Follow the prompts to set a view-only password and a password for your VNC session.

10. Set Hostname: You can set the hostname for your VNC session.

hostnamectl set-hostname hostgui

11. Restart Hostname Service:

systemctl restart systemd-hostnamed

12. Logout and Log Back In: Log out of the root user and log back in with your new username.

13. Create a VNC Session Entry: This step will create a VNC session entry in the .xsession file.

echo xfce4-session ~/.xsession

14. Copy VNC Session Entry to Default Directory:

sudo cp ~/.xsession /etc/skel

15. Modify the VNC Session Entry: This step modifies the VNC session entry in the /etc/skel directory.

Note: The sed command mentioned here might not be necessary if you're setting up for VNC.

sudo sed -i 0/-1/s//ask-1/ 

16. Restart VNC Server:

sudo service xrdp restart

17. Restart the Instance: Restart your EC2 instance.

sudo shutdown -r now

18. Log Back In: Log back in using the root user and run the following command to start the X server.

vncserver :1

19. Install PuTTY: If you want to connect to the VNC server using PuTTY (Windows users only).

apt-get install putty -y

20. Connect to the VNC Server:

For RDP (Windows users): Type mstsc, enter the public IP of your instance, user ID, and password.

public-ip-of-the-instance  user ID and Password

For VNC (Linux or macOS users): Use a VNC client to connect to your instance's IP and port 5901.

Note: Make sure to enable port 5901 in your EC2 security group settings to allow incoming traffic.

Conclusion

Setting up a desktop environment on an EC2 instance can enhance your productivity and make managing your server more user-friendly. This guide provides a comprehensive step-by-step process for installing and configuring Ubuntu Desktop on an Amazon EC2 instance using VNC.

Further Reading

For a detailed step-by-step guide, refer to the following URL:

[URL Link]