Thursday, February 20, 2020

Guacamole Setup on CentOS 7

Here is a step by step guide how to install and configure Apache Guacamole on CentOS7

Step 1. Of course, you need to install a new system. During the installation, remember to set few things to avoid manual change later.

- set time zone
- set network configuration
- set storage
- select minimal server packages
- begin installation
- set root password


Step 2. After installation reboot, it's a good practice to keep your system up-to-date.


# yum update -y


Reboot


Step 3. Install some dependency packages.  The following list all packages to be installed. 

# yum install -y cairo-devel
# yum install -y libjpeg-turbo-devel
# yum install -y libpng-devel
# yum install -y libtool
# yum install -y uuid-devel


# yum install epel-release
# rpm -v --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
# yum install -y ffmpeg-devel
# yum install -y freerdp-devel
# yum install -y pango-devel
# yum install -y libssh2-devel
# yum install -y libtelnet-devel
# yum install -y libvncserver-devel
# yum install -y libwebsockets-devel
# yum install -y pulseaudio-libs-devel
# yum install -y openssl-devel
# yum install -y libvorbis-devel
# yum install -y libwebp-devel

Step 4. Download Apache Guacamole Server source and get it install

you might need this tool.
# yum install -y wget


Download Source (2 ways)

download from website http://guacamole.apache.org or from github

download from website

after getting the url from browser download manager, you can download with wget ( for me, i have the url)


# wget http://apache.communilink.net/guacamole/1.1.0/source/guacamole-server-1.1.0.tar.gz
# tar -xzf guacamole-server-1.1.0.tar.gz
# cd guacamole-server-1.1.0/

download from github

# git clone git://github.com/apache/guacamole-server.git
# cd guacamole-server/
# autoreconf -fi
# ./configure --with-init-dir=/etc/init.d


You should get similar result


# make
# make install
# ldconfig

Now the Guacamole Server is ready.

Step 5. Download Apache Guacamole Client WAR

Download client from website


after getting the url from browser download manager, you can download with wget ( for me, i have the url)
# wget http://ftp.cuhk.edu.hk/pub/packages/apache.org/guacamole/1.1.0/binary/guacamole-1.1.0.war

Step 6. Install Tomcat


# yum install -y tomcat
# yum install -y tomcat-admin-webapps
# yum install -y tomcat-webapps


# vi /usr/share/tomcat/conf/tomcat-users.xml
Uncomment these lines and change the password for admin

<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user name="admin" password="**********" roles="admin,manager,admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status" />
</tomcat-users>





# systemctl enable tomcat
# systemctl restart tomcat

Step 7. Open port 8080 on firewall

# firewall-cmd --add-port=8080/tcp --permanent
# firewall-cmd --reload


now your tomcat should be available
http://:8080/
mine is http://10.10.10.13:8080/


and the manager app should also work at http://10.10.10.13:8080/manager/html
After input the admin user name and  password,


# cp guacamole-1.1.0.war /usr/share/tomcat/webapps/guacamole.war


Then refresh the http://10.10.10.13:8080/manager/html
You will see the app deployed


# mkdir /etc/guacamole
# vi /etc/guacamole/guacamole.properties
# Hostname and port of guacamole proxy
guacd-hostname: localhost
guacd-port:     4822


# vi /etc/guacamole/user-mapping.xml
(this is for testing purpose, change the red parts as needed)

<user-mapping>

   <authorize
            username="testuser"
            password="testpass123">

        <connection name="VNC TEST”>
            <protocol>vnc</protocol>
            <param name="hostname">172.16.10.10</param>
            <param name="port">5900</param>
            <param name="password">******</param>
        </connection>

        <connection name="SSH TEST">
            <protocol>ssh</protocol>
            <param name="hostname">10.10.10.25</param>
            <param name="port">22</param>
        </connection>

        <connection name="RDP TEST">
            <protocol>rdp</protocol>
            <param name="hostname">172.16.10.19</param>
            <param name="port">3389</param>
        </connection>

    </authorize>

</user-mapping>


# systemctl enable guacd
# systemctl restart tomcat guacd


Step 8.  Testing - without Database

http://10.10.10.13:8080/guacamole


Try to click any of connections for testing 
During session connected, you can use CTRL+ALT+SHIFT to call the GUACAMOLE menu for disconnections (under top right corner choose testuser->disconnect) 

Step 9 - Integrating with MySQL/MariaDB for larger scale of usage.

# yum install -y mariadb
# systemctl start mariadb


Or install mysql-server (non-bundled in CentOS7)


# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum update
# yum install mysql-server
# systemctl start mysqld

# mysql_secure_installation


[root@guaca ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] 
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] 
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] 
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] 
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] 
 ... Success!



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...
[root@guaca ~]# 


Create Database
[root@guaca ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.47 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database guacamole_db;
Query OK, 1 row affected (0.00 sec)

mysql> create user 'guacamole_user'@'localhost' identified by 'hv@99sw';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole_user'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
[root@guaca ~]#




Download the extension  guacamole-auth-jdbc….tar.gz
[root@guaca ~]# wget http://apache.communilink.net/guacamole/1.1.0/binary/guacamole-auth-jdbc-1.1.0.tar.gz
[root@guaca ~]# tar zxvf guacamole-auth-jdbc-1.1.0.tar.gz
[root@guaca ~]# cd guacamole-auth-jdbc-1.1.0/mysql/
[root@guaca mysql]# mkdir /etc/guacamole/extensions
[root@guaca mysql]# cat schema/*.sql | mysql -u root -p guacamole_db
Enter password: 
[root@guaca mysql]# cp guacamole-auth-jdbc-mysql-1.1.0.jar /etc/guacamole/extensions/


Download mysql jdbc driver


[root@guaca ~]# wget https://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-8.0.19.tar.gz
[root@guaca ~]# tar zxvf mysql-connector-java-8.0.19.tar.gz
[root@guaca ~]# mkdir /etc/guacamole/lib
[root@guaca ~]# cp mysql-connector-java-8.0.19/mysql-connector-java-8.0.19.jar /etc/guacamole/lib/


[root@guaca ~]# vi /etc/guacamole/guacamole.properties


Add the bolded part
# Hostname and port of guacamole proxy
guacd-hostname: localhost
guacd-port:     4822

# MySQL properties
mysql-hostname: localhost
mysql-port: 3306
mysql-database: guacamole_db
mysql-username: guacamole_user
mysql-password: ********


Disable the user-mapping and apply the database configurations
[root@guaca ~]# mv /etc/guacamole/user-mapping.xml /etc/guacamole/user-mapping.xml.bak
[root@guaca ~]# systemctl restart guacd tomcat


http://10.10.10.13:8080/guacamole 
Login with guacadmin/guacadmin and change password before any further administrations


Add some connections for testing
Add a user and assign connection privileges for testing


Login the new user and enjoy


No comments: