导航:[首页]->[other]->[使用novnc实现vnc web化]

安装

下载novnc压缩包

解压到linux某目录,确保linux安装有python

使用

root@qjw-VirtualBox:~/kanaka-noVNC-afbeb98/utils# ./websockify.py --web=./.. 5900 192.168.2.21:5900
WARNING: no 'numpy' module, HyBi protocol will be slower
WebSocket server settings:
  - Listen on :5900
  - Flash security policy server
  - Web server. Web root: /root/kanaka-noVNC-afbeb98
  - No SSL/TLS support (no cert file)
  - proxying from :5900 to 192.168.2.21:5900

访问http://192.168.1.8:5900/vnc.html或者http://192.168.1.8:5900/vnc_auto.html

Unix Socket

root@qjw-VirtualBox:~/kanaka-noVNC-afbeb98/utils# ./websockify.py --web=./.. 5900 --unix-target /tmp/fuck
WARNING: no 'numpy' module, HyBi protocol will be slower
WebSocket server settings:
  - Listen on :5900
  - Flash security policy server
  - Web server. Web root: /root/kanaka-noVNC-afbeb98
  - No SSL/TLS support (no cert file)
  - proxying from :5900 to /tmp/fuck

多目标

root@qjw-VirtualBox:~/kanaka-noVNC-afbeb98/utils# ./websockify.py --web=./.. 5900 --target-config=/tmp/fuck
WARNING: no 'numpy' module, HyBi protocol will be slower
WebSocket server settings:
  - Listen on :5900
  - Flash security policy server
  - Web server. Web root: /root/kanaka-noVNC-afbeb98
  - No SSL/TLS support (no cert file)
  - proxying from :5900 to targets in /tmp/fuck

 14: 192.168.1.5: Plain non-SSL (ws://) WebSocket connection
 14: 192.168.1.5: Version hybi-13, base64: 'False'
 14: 192.168.1.5: Path: '/websockify'
 14: 192.168.1.5: Token not present
 21: 192.168.1.5: Plain non-SSL (ws://) WebSocket connection
 21: 192.168.1.5: Version hybi-13, base64: 'False'
 21: 192.168.1.5: Path: '/websockify/?token=abcdefg'
 21: connecting to: 192.168.1.8:5900

root@qjw-VirtualBox:/tmp/fuck# ls
a
root@qjw-VirtualBox:/tmp/fuck# cat a 
abcdefg: 192.168.1.8:5900

访问http://192.168.1.8:5900/vnc_auto.html?path=websockify/?token=abcdefg后面的部分注意url编码

加密

openssl req -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xA25Bpjkf71+fOodzPrCS01U00io/5rjf+c5PEL2/nYO1MshvImGSVagD
94atDMlJtdyR/iar9tIrfYjBKE9Y63ztz1EkS2mf0EQiy1U54G6fPx6xIKq1J+O4
nCBFp0e0BsRzitDU0G2qMNCjhZpnxQCXaeEQj2CWtFOQOToZWl+WPYvRYUAFvt3/
QtkoiQvnX59VJepgLHJ3hrXGAWVlMFOUkTukDJX6+RC7QRFfFoBGKt5vsOcWWNR5
LmEhmxeCvmOAZHYQDq3IjveJhkILXwIDAQABo1AwTjAdBgNVHQ4EFgQUB25LY2tn
OzdOhH+Lgueje09QT04wHwYDVR0jBBgwFoAUB25LY2tnOzdOhH+Lgueje09QT04w
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAcoSwZnTquzLR9E9uMHCS
j2XshEVSYLi2AkKvk3wTF4cKzRvKs8V9Us4V5romsDW5kdqN+MXSNv72IPtXcuMY
3Ow+2yQS3TOKxNnLIOPze2MR8AMq8n1UvoxPbIZ1hGifgUEgGlaxo8e9NJdvKRio
WzPMW4rPIkYL7CYnsYtaNVgP3gxZJEA1gEJlESeBcBOaX5NjOIdK1lhzn05wwfDz
oRvjjv8LueIhiwr9+HQiZdglKyvFHRpQqOuMnaSP+L9crgMLNk0ueWBI6ln2rukp
LBOIBY30pDuQK6Y6gwTJHaqZB1T/NtxkzSANUlYgjVKPCygLt06yimNLbW27s1yp
6Q==
-----END CERTIFICATE-----   

./websockify.py --web=./.. 5900 --target-config=/tmp/fuck --cert self.pem

若证书和私钥分别位于两个文件中,可以

./websockify.py --web=./.. 5900 --target-config=/tmp/fuck --cert self.pem --key self.key

默认情况下,仍然可以用非加密方式访问,--ssl-only可以禁止此行为。

参考

  1. http://kanaka.github.io/noVNC/
  2. http://www.vpsee.com/2013/07/integrating-novnc-with-our-vm-control-panel/
  3. http://xiexiejiao.cn/java/html5-instance-html5-novnc-client.html
  4. http://blog.csdn.net/hongqun/article/details/17098633
  5. http://stackoverflow.com/questions/6391005/novnc-to-x11vnc-ssl-connection