GuacamoleHTML5无客户端远程桌面

1.Guacamole一基于HTML5的远程桌面控制框架,性能较高,官方说接近于原生的VNC。具体介绍及安装方法,见http://guac-dev.org/

2.本文使用Guacamole远程访问KVM虚拟机,这需要对/etc/guacamole/user-mapping.xml配置,指定运行的各KVM虚拟机的端口

3.在一个云计算项目中,需要整合该框架,达到访问虚拟机的时候不要再次验证。如:http://192.168.32.107:8080/guacamole/?port=5901,其中port为要访问的kvm虚拟机的端口。

a. 修改tomcat/webapps/guacamole的index.xhtml

		function loginAuto(){
			var port=window.location.search;
			if(port=="")return;
			port=port.substring(6);
			var username = port;
                	var password = port;
	                var data =
	                       "username=" + encodeURIComponent(port)
	                    + "&password=" + encodeURIComponent(port)

	                try {
	                    // Log in
	                    var xhr = new XMLHttpRequest();
	                    xhr.open("POST", "login", false);
	                    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	                    xhr.send(data);
	                    // Handle failures
	                    if (xhr.status != 200)
	                        throw new Error("Invalid login");
	                    resetUI();
	                }
	                catch (e) {
	
	                    var loginError = document.getElementById("login-error");
	                    // Display error, reset and refocus password field
	                    loginError.textContent = e.message;
	                    password.value = "";
	                    password.focus();
	                    return false;
	                }
	                // On success, hide loginUI, get and show connection list.
           	     	return false;
		}



<body onload="loginAuto()">...</body>

b.修改user-mapping.xml,授权

<authorize password="5901" username="5901"> 
	<protocol>vnc</protocol> 
	<param name="hostname">localhost</param> 
	<param name="port">5901</param> 
	<param name="password">VNCPASS</param> 
</authorize> 
<authorize password="5910" username="5910"> 
	<protocol>vnc</protocol> 
	<param name="hostname">localhost</param> 
	<param name="port">5910</param> 
	<param name="password">VNCPASS</param> 
</authorize> 



原文地址:https://www.cnblogs.com/whuqin/p/4982050.html