Operate Windows remote desktop and linux through browser html5, and remember the installation and use of Apache Guacamole

Posted by nmarisco on Fri, 17 Dec 2021 00:22:31 +0100

Recently, the function of accessing linux and windows through web version and html has been used in the project. I found that Apache Guacamole has such a function. Therefore, the test experience is very good. Record it for future reference.

1, Introduction to Apache Guacamole

Official website: https://guacamole.apache.org/

The main thing mentioned above is that Apache Guacamole is a remote desktop program that can be accessed without a client. It supports standard VNC,RDP,ssh, etc. Therefore, it can be used like windows remote desktop and linux ssh. It can be used directly by using html5 and a browser.

2, Apache guacamole architecture

The architecture diagram is as follows:
·Apache Guacamole Server is mainly composed of two parts, guacamole and guacd. Users connect guacamole program through browser. Guacamole is deployed in tomcat and implemented in java, while guacd is implemented in c. The general process is: HTML5 web browser - > guacamole - > guacd - > (RDP / VNC / sh, etc.)

3, Guacamole server deployment

Now there are several versions, some with pits and some normal. After several versions of trial, it is finally determined that 1.2 Version 0 is my choice, https://guacamole.apache.org/releases/1.2.0/

  1. ##Download
wget https://archive.apache.org/dist/guacamole/1.2.0/source/guacamole-server-1.2.0.tar.gz
  1. ##Prepare the installation of some yum components before compiling

reference resources: https://guacamole.apache.org/doc/gug/installing-guacamole.html#required-dependencies

yum install -y gcc gcc-c++
yum install -y cairo-devel
yum install -y libjpeg-turbo-devel
yum install -y libjpeg-devel
yum install -y libpng-devel
yum install -y libtool
yum install -y uuid-devel
yum install -y freerdp-devel
yum install -y pango-devel
yum install -y libssh2-devel
yum install -y libvncserver-devel
yum install -y pulseaudio-libs-devel
yum install -y openssl-devel
yum install -y libvorbis-devel
yum install -y libwebp-devel
  1. ##Compile
tar xvf guacamole-server-1.2.0.tar.gz
cd guacamole-server-1.2.0/
autoreconf -fi
./configure --with-init-dir=/etc/init.d
make
make install
ldconfig
  1. ##Start and stop
##start-up
/etc/init.d/guacd start

##stop it
/etc/init.d/guacd stop
##restart
/etc/init.d/guacd restart
  1. ##Post startup inspection

After guacamole server is started, it will occupy port 4822 and reside as a process. View it through the netat -luntp command

[root@localhost guacamole-server-1.2.0]# /etc/init.d/guacd start
Starting guacd: guacd[12900]: INFO:     Guacamole proxy daemon (guacd) version 1.2.0 started
SUCCESS
##View the port online through the command
netstat -luntp

##If the netstat command cannot be found, execute the installation of net tools
yum install -y net-tools
[root@localhost guacamole-server-1.2.0]# netstat -luntp|grep guacd
tcp        0      0 127.0.0.1:4822          0.0.0.0:*               LISTEN      14029/guacd      

4, Guacamole Client Deployment

  1. ##jdk installation (can be installed by your own side). My installation process is as follows
tar -xvf jdk-8u191-linux-x64.tar.gz -C /usr/local

cat >> /etc/profile << EOF

export JAVA_HOME=/usr/local/jdk1.8.0_191/
export PATH=\$JAVA_HOME/bin:\$PATH
export CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
EOF

source /etc/profile
  1. ##Prepare tomcat and download one directly from the official website
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.52/bin/apache-tomcat-9.0.52.tar.gz

##Unzip Tomcat (Jdk support is required, install in advance, omitted)
tar xvf apache-tomcat-9.0.52.tar.gz
  1. ##Prepare the war package in an optional manner

##Method 1: download the ready-made war package directly on the Internet

wget https://archive.apache.org/dist/guacamole/1.2.0/binary/guacamole-1.2.0.war

##Method 2: generate the war package by downloading the source code compilation. After compilation, the corresponding war file will be generated at the target in the guacamole directory

wget https://archive.apache.org/dist/guacamole/1.2.0/source/guacamole-client-1.2.0.tar.gz

##Compile through maven to generate war package
mvn clean package


3. ##war package is placed under webapp of tomcat

[root@localhost webapps]# pwd
/root/apache-tomcat-9.0.52/webapps
[root@localhost webapps]# ls -hl
total 12M
drwxr-x---. 15 root     root     4.0K Sep  2 10:19 docs
drwxr-x---.  7 root     root       99 Sep  2 10:19 examples
-rw-rw-r--.  1 testuser testuser  12M Sep  1 15:22 guacamole-1.2.0.war
drwxr-x---.  6 root     root       79 Sep  2 10:19 host-manager
drwxr-x---.  6 root     root      114 Sep  2 10:19 manag
  1. ##Create guacamole configuration files and directories
mkdir /etc/guacamole/
  1. ##Create guacamole Properties file
vi /etc/guacamole/guacamole.properties
guacd-hostname: localhost
guacd-port: 4822
user-mapping.xml: /etc/guacamole/user-mapping.xml
enable-clipboard-integration: true
  1. ##Create user mapping XML file

The following example configures a windows remote access and a linux ssh protocol access
vi /etc/guacamole/user-mapping.xml

<user-mapping>
        <authorize password="123456" username="admin"> #Login interface account password

        <connection name="rdp-192.168.60.18">
                <protocol>rdp</protocol>  #RDP protocol configuration        
                <param name="hostname">192.168.60.18</param> #Remote host IP
                <param name="port">4389</param> #rdp default port        
                <param name="username">testuser</param> #Remote host user        
                <param name="password">123456</param> #Remote host user password        
                <param name="ignore-cert">true</param>
        </connection>

        <connection name="ssh-172.168.201.148">
                <protocol>ssh</protocol>
                <param name="hostname">172.168.201.148</param>
                <param name="port">55314</param>
                <param name="username">testuser</param>
                <param name="password">123456</param>
                <param name="enable-sftp">true</param>  #sftp parameter configuration (if it is not installed, the following sftp does not need to be added)
                <param name="sftp-hostname">172.168.201.148</param>
                <param name="sftp-root-directory">/home/testuser</param>
                <param name="sftp-username">testuser</param>
                <param name="sftp-password">123456</param>
                <param name="color-scheme">white-black</param> #Remote login display font color
        </connection>

      </authorize>
</user-mapping>

Note: detailed configuration reference https://guacamole.apache.org/doc/gug/configuring-guacamole.html
8. ##tomcat starts and then performs access test

cd /root/apache-tomcat-9.0.52/bin/
./startup.sh

Access address such as: http://192.168.56.101:8080/guacamole-1.2.0/
Account password: admin / 123456 (configured in user-mapping.xml)

The access effect of linux is as follows:

Windows 7 remote access effect

5, Font setting (you can try it in case of garbled code)

If garbled code is found, you can try to set the font as follows:

  1. ##Check if fontconfig is installed
cd /usr/share/fonts/

##If there is no directory, execute

  1. ##Copy fonts in windows system, select Song typeface and bold typeface,

window font location: C:\Windows\Fonts
simsun.ttc
simhei.ttf

  1. ##Put fonts into linux
##Create a new directory chinese under / usr/shared/fonts
mkdir /usr/shared/fonts/chinese

##Place two fonts under windows in this directory
[root@localhost chinese]# ls -hl /usr/share/fonts/chinese
total 27M
-rw-r--r--. 1 root root 9.4M Mar  2  2019 simhei.ttf
-rw-r--r--. 1 root root  18M Mar 19  2019 simsun.ttc
  1. ##Update font cache and view
##In memory font cache
fc-cache

##You can view a list of fonts
fc-list

Topics: Linux Windows html5