Hello friends, You may be using VNCserver, RDP, ssh, etc to access your device remotely whether it is Windows, mac or Linux, you need to install their clients to access it. And its become frustrating to install it on every time, So In this blog we will see a tool called Apache Guacamole which is used to access all these services directly from your browser without installing any of their clients, And the best part is that we can do this all just on your smartphone.
Apache Guacamole is a open-source tool developed by Apache Software Foundation. It is used to access remote services like VNC, RDP, ssh without installing their clients, you can access all those services directly from your web browser.
Prerequisite
Ubuntu 20.04 (or lower) or Debian, I am using Debian with proot-distro in Termux, If you don't know how to install it, click here.
Install Guacamole server
First we need to install dependencies, execute following to installing it
sudo apt install wget default-jdk build-essential libcairo2-dev libjpeg62-turbo-dev \ libpng-dev libtool-bin libossp-uuid-dev libvncserver-dev \ freerdp2-dev libssh2-1-dev libtelnet-dev libwebsockets-dev \ libpulse-dev libvorbis-dev libwebp-dev libssl-dev \ libpango1.0-dev libswscale-dev libavcodec-dev libavutil-dev \ libavformat-dev
If you are using Ubuntu, then replace libjpeg62-turbo-dev with libjpeg-turbo8-dev
Once dependencies are installed, then get guacamole server source code
wget https://downloads.apache.org/guacamole/1.3.0/source/guacamole-server-1.3.0.tar.gz
Extract the file and change directory to it.
tar -xvf guacamole-server-1.3.0.tar.gz && cd guacamole-server-1.3.0
Now build the guacamole server,
sudo ./configure --with-init-dir=/etc/init.d
sudo make
sudo make install
sudo ldconfig
Start guacd service
sudo service guacd start
Install Apache Tomcat web app
Get Apache Tomcat
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz
Create a directory for installing it
sudo mkdir -p /opt/tomcat
Extract the file in the directory that we created
tar -xvf apache-tomcat-9.0.65.tar.gz -C /opt/tomcat --strip-components=1
Creating service file for it, so that we can directly start it with service command
open the file with a text editor
nano /etc/init.d/tomcat
Get java path and copy it
update-java-alternatives -l
paste the following code in it and make sure to change JAVA_PATH to the path you copied
#!/bin/bash
export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-arm64
export PATH=$JAVA_HOME/bin:$PATH
TOMCAT_HOME=/opt/tomcat
TOMCAT_USER=root
start() {
echo "Starting Tomcat..."
/bin/su -p -s /bin/sh $TOMCAT_USER $TOMCAT_HOME/bin/startup.sh >> /dev/null
echo "Tomcat Started"
return 0
}
stop() {
echo "Stoping Tomcat..."
/bin/su -p -s /bin/sh $TOMCAT_USER $TOMCAT_HOME/bin/shutdown.sh >> /dev/null
echo "Tomcat Stopped"
return 0
}
usage(){
echo "Usage: start | stop | restart"
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
usage
;;
esac
exit 0
Give executable permission
chmod 755 /etc/init.d/tomcat
Get Guacamole client
wget https://downloads.apache.org/guacamole/1.3.0/binary/guacamole-1.3.0.war
Move it to tomcat directory
sudo mv guacamole-1.3.0.war /opt/tomcat/webapps/guacamole.war
Restart both service tomcat and guacd
sudo service restart tomcat
sudo service restart guacd
Setting up Database Authentication
Install Mysql or MariaDB
sudo apt install mariadb-server && sudo apt install mariadb-client
Create Directories for extensions and library in guacamole
mkdir -p /etc/guacamole/{extensions,lib}
Get mysql connector
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.26.tar.gz
Extract the file and copy it /etc/guacamole/lib
tar -xf mysql-connector-java-8.0.26.tar.gz
sudo cp mysql-connector-java-8.0.26/mysql-connector-java-8.0.26.jar /etc/guacamole/lib/
Get JDBC auth plugin for Apache Guacamole. You can get it from http://guacamole.apache.org/releases/
wget https://downloads.apache.org/guacamole/1.3.0/binary/guacamole-auth-jdbc-1.3.0.tar.gz
Extract the file and move to /etc/guacamole/extensions/
tar -xf guacamole-auth-jdbc-1.3.0.tar.gz
sudo mv guacamole-auth-jdbc-1.3.0/mysql/guacamole-auth-jdbc-mysql-1.3.0.jar /etc/guacamole/extensions
Start mariadb service
sudo service mariadb start
Start mysql service
sudo mysql
Now execute following commands to setup database for guacamole and make sure to change password with the password you want
CREATE DATABASE guacamole_db;
CREATE USER 'guacamole_user'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole_user'@'localhost';
FLUSH PRIVILEGES;
Exit from mysql
exit
Change the directory to Extracted directory for JDBC auth plugin
cd guacamole-auth-jdbc-1.3.0/mysql/schema
Import those sql schema into mysql database
cat *.sql | mysql -u root -p guacamole_db
Create properties file for guacamole
sudo nano /etc/guacamole/guacamole.properties
Paste the following in it and make sure to change password with the password with your password
# MySQL properties
mysql-hostname: 127.0.0.1
mysql-port: 3306
mysql-database: guacamole_db
mysql-username: guacamole_user
mysql-password: password
Restart all related services
sudo service tomcat restart
sudo service guacd restart
sudo service mariadb restart
Now our setup is completed, Open your browser and go to <your IP>:8080
You will get a login prompt, Login with guacadmin for both username and password.