问题1: 在guacamole-server.1.4.0目录下,执行./configure,发现记录中出现以下警告,并且VNC没有成功加载(libvncserver.devel已经导入yum的情况下)
libvncserver appears to be built against
libgcrypt, but the libgcrypt headers
could not be found. VNC will be disabled.
解决: 需要加载 libgcrypt: 执行yum -y install crypt*(一般执行这一步就可以了);yum install libgcrypt*(可以不支执行)
简单安装步骤:
1、下载guacamole相关资源包:Apache Guacamole™: 1.4.0
2、guacamole相关依赖参考官网-Installing Guacamole natively — Apache Guacamole Manual v1.4.0
预备安装
yum install gcc
基础依赖
yum -y install cairo-devel libjpeg-turbo-devel libpng-devel uuid-devel
扩展依赖,如VNC、RDP、SSH协议等等
yum -y install ffmpeg-devel(如果导入失败,则执行以下操作,安装ffmpeg时间有点长)
安装ffmpeg时需要提前安装yasm插件。下面开始安装
# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
# tar -xvf yasm-1.3.0.tar.gz
# cd yasm-1.3.0/
# ./configure && make && make install
添加可选依赖
yum -y install cairo-devel libjpeg-turbo-devel libpng-devel uuid-devel
yum -y install freerdp-devel pango-devel
yum -y install libssh2-devel libtelnet-devel libvncserver-devel libwebsockets-devel
yum -y install pulseaudio-libs-devel openssl-devel
yum -y install libvorbis-devel libwebp-devel
开始安装ffmpeg,时间有点长
# wget http://ffmpeg.org/releases/ffmpeg-4.2.2.tar.gz
# tar -xvf ffmpeg-4.2.2.tar.gz
# cd ffmpeg-4.2.2/
# ./configure && make && make install
解压之前下载好的服务端包:guacamole-server-1.4.0.tar.gz
tar -zxvf guacamole-server-1.4.0.tar.gz
cd guacamole-server-1.4.0
预编译,并检查添加依赖是否生效
./configure --with-init-dir=/etc/init.d
make && make install
ldconfig
因为我这边只需要安装服务端,只需要在/etc/guacamole目录下新增配置文件guacd.conf:
[daemon]
pid_file = /var/run/guacd.pid
log_level = info
[server]
bind_host = 0.0.0.0
bind_port = 4822
[ssl]
server_certificate = /etc/ssl/certs/guacd.crt
server_key = /etc/ssl/private/guacd.key
简单写springboot 集成自定义guacamole客户端,为了方便使用我采用集成GuacamoleWebSocketTunnelEndpoint
@Override
public GuacamoleTunnel createTunnel(Session session, EndpointConfig endpointConfig) throws GuacamoleException {
System.out.println("createTunnel WebSocket start");
String guacaMoleHostName = "127.0.0.1"
int guacaMolePort = 4822;
// 获取前端参数
Map<String, List<String>> requestMap = session.getRequestParameterMap();
Integer height = Integer.valueOf(getMapByKey(requestMap, "height"));
Integer width = Integer.valueOf(getMapByKey(requestMap, "width"));
GuacamoleClientInformation information = new GuacamoleClientInformation();
// information.setOptimalScreenHeight(height);
// information.setOptimalScreenWidth(width);
// 获取远程服务器相关信息
String protocol = getMapByKey(requestMap, "protocol");
String port = getMapByKey(requestMap, "port");
String hostName = getMapByKey(requestMap, "hostName");
String userName = getMapByKey(requestMap, "userName");
String password = getMapByKey(requestMap, "password");
String dataTime = DateUtils.getNowTime(SysConstant.DATE_LONG_PATTERN);
// 通过自定义SpringContextUtils获取springboot容器内的bean
ComServerServiceImpl comServerService = SpringContextUtils.getBean(ComServerServiceImpl.class);
GuacamoleConfiguration configuration = new GuacamoleConfiguration();
// 注意:后台不要自定义configuration.setConnectionID, 否则前端无法连接tunnel
configuration.setProtocol(protocol);
configuration.setParameter("hostname", hostName);
configuration.setParameter("port", port);
configuration.setParameter("username", userName);
configuration.setParameter("password", password);
configuration.setParameter("ignore-cert", "true");
// String fileName = DateUtils.getNowTime() + ".guac";//文件名
// String outputFilePath = "/home/guacamole";
// //添加会话录制--录屏
// configuration.setParameter("recording-path", outputFilePath);
// configuration.setParameter("create-recording-path", "true");
// configuration.setParameter("recording-name", fileName);
GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
new InetGuacamoleSocket(guacaMoleHostName, guacaMolePort),
configuration,
information
);
GuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
System.out.println("createTunnel WebSocket success");
return tunnel;
}
前端html测试代码
var encodePara = "34d8b7e8c4145911969f9246688ad39c4a";
var param = "sid="+sid+"&height=768&width=1024&protocol=rdp&port=3389&hostName=116.196.106.221&userName=administrator&password="+encodePara;
var guac = new Guacamole.Client(
//new Guacamole.HTTPTunnel("/guacamole/tunnel")
// websoket "&":表示结束,注意特殊字符encodeURIComponent(val)编码
new Guacamole.WebSocketTunnel("/webSocket?"+ param +"&")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
alert(JSON.stringify(error));
};
param = "height=768&width=1024&protocol=ssh&port=22&hostName=172.17.5.9&userName=test&password=test";
// httpServlet request params Connect
guac.connect(/*param*/);
// Disconnect on close
window.onunload = function() {
guac.disconnect();
}
参考地址:Guacamole系列一:服务端安装_橄榄丝的博客-CSDN博客_guacamole安装
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)