Guacamole介绍与安装

802 阅读3分钟

“开启掘金成长之旅!这是我参与「掘金日新计划 · 2 月更文挑战」的第 5 天,点击查看活动详情

1.介绍

我们在日常开发和部署过程中经常遇到可能环境22端口被封禁,无法进行SSH,从而导致无法连接后台,影响定位问题。 今天给大家介绍一个通过web访问ssh的工具——Guacamole。安装项目的过程中把Guacamole安装在Liunx系统中,这样就可以从web界面访问ssh,跳过22端口封禁的限制。 Guacamole安装分为guacamole-server(服务端)用于直接连接服务器的底层,和guacamole-client(客户端)包括前端展示,包括用户,权限,连接管理,以及连接服务器的分辨率,ftp文件传输,个性化设置等业务需求的完善。下面我们就看看如何安装Guacamole。

2.安装Guacamole-Server

1.安装环境

rpm --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-1.el7.nux.noarch.rpm yum update -y    

  1. 安装依赖

yum -y install cairo-devel libjpeg-devel libpng-devel uuid-devel yum -y install ffmpeg-devel  freerdp-devel pango-devel libssh2-devel yum -y install libtelnet-devel libvncserver-devel pulseaudio-libs-devel

yum -y install openssl-devel libvorbis-devel libwebp-devel

yum -y install freerdp-plugins

yum install cairo-devel libjpeg-turbo-devel libjpeg-devel libpng-devel uuid-devel wget gcc gcc-c++    

默认Centos没有FFmpeg软件包,我这里需要借助第三方的yum源

yum install   http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm``

yum install ffmpeg-devel yum install libvncserver-devel freerdp1.2-devel libssh2-devel openssl-devel pango-devel libtelnet-devel pulseaudio-libs-devel libvorbis-devel libwebp-devel

安装包下载:

wget https://mirrors.tuna.tsinghua.edu.cn/apache/guacamole/1.1.0/source/guacamole-server-1.1.0.tar.gz  

解压并安装:

tar -zxvf guacamole-server-1.1.0.tar.gz mv guacamole-server-1.1.0 guacamole-server cd /usr/local/src/guacamole-server ./configure --with-init-dir=/etc/init.d  

image.png

(以上三个环境配置成功)

make && make install                  

启动 guacamole-server 使用的命令:

service guacd restart  

(以上三个环境配置成功)

make && make install                  

启动 guacamole-server 使用的命令:

service guacd restart

至此服务端安装完成

3. 安装Guacamole-client  

Guacamole客户端是java web应用,需要做以下准备安装:

jdk

servlet容器(tomcat)

此处省略以上环境安装步骤,请自行百度。

1.从官网 guacamole.apache.org/releases/1.… 下载WEB应用(guacamole-1.1.0.war)

2.配置guacamole:

mkdir /etc/guacamole/ # cd /etc/guacamole/ # vi guacamole.properties              

guacamole.properties文本内容配置文件存储认证信息:

guacd-hostname: localhost

guacd-port:     4822

enable-websocket: true

enable-clipboard-integration: true auth-provider: net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider basic-user-mapping: /etc/guacamole/user-mapping.xml    

 

guacamole有2种连接管理方式,一种使用xml方式,另一种使用mysql

3.1 xml方式

在/etc/guacamole/目录下创建user-mapping.xml文件:

<user-mapping>

<authorize  password="guacadmin" username="guacadmin"> <connection name="rdp-windows-15">

<protocol>rdp</protocol>          

<param name="hostname">192.168.1.15</param>

<param name="port">3389</param>          

<param name="username">admin</param>          

<param name="password">123456</param>          

<param name="ignore-cert">true</param>      

</connection>      

<connection name="ssh-192.168.1.14">

<protocol>ssh</protocol>          

<param name="hostname">192.168.1.14</param>

<param name="port">22</param>          

<param name="username">admin</param>          

<param name="password">123456</param>          

<param name="enable-sftp">true</param>          

<param name="sftp-hostname">192.168.1.14</param>

<param name="sftp-root-directory">/</param>

<param name="sftp-username">admin</param>          

<param name="sftp-password">123456</param>

</connection> </authorize></user-mapping>  

 3.复制guacamole-1.1.0.war到tomcat并启动:

mv ./guacamole-1.1.0.war /opt/apache-tomcat-8.5.42/webapps              

启动tomcat:

 # sh /opt/apache-tomcat-8.5.42/bin/start.sh              

 

配置完成,浏览器打开地址:http://ip:port//guacamole/#/

登录账号/密码:guacadmin/guacadmin

3.2 Mysql数据库配置:

  1. 创建一些目录

mkdir -p /etc/guacamole/ mkdir -p /etc/guacamole/extensions mkdir -p /etc/guacamole/lib mkdir -p /etc/guacamole/sqlauth/              

  1. 在本地数据库建新的数据库guacamole_db:

下载guacamole-auth-jdbc-1..0.tar.gz解压文件\guacamole-auth-jdbc1.0.0\mysql\schema\目录下的两个.sql文件执行初始化

  1. 编辑配置文件

vi /etc/guacamole/guacamole.properties

内容如下(数据库的资料需要与上文配置的参数相同):

####guacamole.properties####

guacd-hostname: localhost

guacd-port: 4822 #

user-mapping: /etc/guacamole/user-mapping.xml

# MySQL properties

mysql-hostname: localhost

mysql-port: 3306

mysql-database: guacamole_db

mysql-username: guacamole

mysql-password: guacamole

####guacamole.properties####    

4.guacmole 安装数据库扩展驱动

yum -y install java-1.8.0-openjdk* cd /etc/guacamole/sqlauth wget https://mirrors.tuna.tsinghua.edu.cn/apache/guacamole/1.1.0/binary/guacamole-auth-jdbc-1.1.0.tar.gz tar -zxvf guacamole-auth-jdbc-1.1.0.tar.gz cp guacamole-auth-jdbc-1.1.0/mysql/guacamole-auth-jdbc-mysql-1.1.0.jar /etc/guacamole/extensions/   wget http://ftp.ntu.edu.tw/MySQL/Downloads/Connector-J/mysql-connector-java-5.1.48.tar.gz tar -xzvf mysql-connector-java-5.1.48.tar.gz cp mysql-connector-java-5.1.48/mysql-connector-java-5.1.48-bin.jar /etc/guacamole/lib/  

5.重启 tomcat

配置完成,浏览器打开地址:http://ip:port//guacamole/#/

默认登录账号/密码:guacadmin/guacadmin

登录即可。

image.png