How to Connect to AWS EC2 Instance using Guacamole?

Apache Guacamole
Reading Time: 4 minutes

Introduction to Guacamole

Hey readers, so today we will be looking into Guacamole and how can we connect to an AWS EC2 instance using Guacamole.

Apache Guacamole is free and open-source software. It is an HTML5 web application that provides access to desktop environments using different protocols. It also produces web applications and provides an API that drives them. Guacamole is most commonly used to refer to the web application produced by the guacamole project using their API. It provides a common and efficient means of streaming text data over a javaScript-based tunnel using either HTTP or WebSocket, and a client implementation that supports the Guacamole protocol and renders the remote display when combined with a Guacamole protocol stream from the tunnel.

Guacamole is a tool that allows access to one or more desktops from anywhere remotely without any client to be installed on another side.

Installing Guacamole

For installing Guacamole on your system, I would prefer to install Guacamole using docker. After installing Guacamole on your system, it creates a lot of system files and creates chaos in your system so I would recommend you all to install using Docker.

docker run -p 8080:8080 -v /path/to/config>:config oznu/guacamole

The above command will pull the Guacamole image and will run it as a container in your Docker environment.

How to Connect to AWS EC2 Instance using Guacamole?

In the above image, you can see the second container running f4745773dd58, and in the ports section, a port number is also mentioned like 0.0.0.0:49155. Then go to the browser and in the search section, write localhost:49155/guacamole. You can see the admin page below:

How to Connect to AWS EC2 Instance using Guacamole?

Then the default credentials are guacadmin:guacadmin. After logging in, you can see the console as below:

How to Connect to AWS EC2 Instance using Guacamole?

As you can see a few connections are there. so for making a new connection, go to the top right corner and click on the guacadmin. From there click on the settings option. After that, you can see the settings below:

How to Connect to AWS EC2 Instance using Guacamole?

Then go to the Connections tab. You will see the configurations page below:

First, you have to give a name to your connection. Then select the protocol type to SSH. Then under the Connectivity Limits section, give both the fields a number like 100.

Generating SSH key

Before moving forward to other sections, I would like you all to start an EC2 instance on AWS. After creating the instance, create SSH keys on the system to that you want your EC2 to be connected.

ssh-keygen -t rsa -b 4096 -m PEM

Two keys will be generated after running the above command. During the key generation process, a prompt will come to you to create a passphrase. You have to create a passphrase of at least 5 characters or digits and remember that passphrase as you have to enter it into the settings of the connection.

After that, copy the public IP of your EC2 instance in the hostname under the Parameters section. Give port number 22. Then under the authentication section, give username as ubuntu. and in the private key, copy the private key that you have generated using the above command. After that, enter the passphrase as well as shown below:

Save this configuration and go to the home of your guacamole by navigating through the top-right menu.

After that, copy the public SSH key and go to your EC2 instance. Change the directory to ssh and add that public key to the authorized keys file and save that. Now we are done with setting the connection. Go to your guacamole home and it will look like as shown below:

Now click on the connection that you have made and will be redirected to the instance prompt like below:

As you can see that we can access the EC2 instance from our system by installing nothing on the instance. So by using Guacamole, we can connect to the local instance too. For more knowledge, click here.

knoldus

Written by 

Shubham Saini is a DevOps Engineer who loves to play with DevOps tools, Security methods and is also interested in Ethical Hacking & Cyber Security. He is a gamer also.