[转载] Ubuntu 16.04 LTS 一键安装VNC

  1. 安装 X11VNC:
    sudo apt install x11vnc -y
  2. 配置访问密码:
    sudo x11vnc -storepasswd /etc/x11vnc.pass
  3. 创建服务:

    vi /lib/systemd/system/x11vnc.service

     1 #粘贴如下代码,最后 :wq 保存,请使用root用户,否则没有权限。
     2 [Unit]
     3 Description=Start x11vnc at startup.
     4 After=multi-user.target
     5 [Service]
     6 Type=simple
     7 ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared
     8 [Install]
     9 WantedBy=multi-user.target
    10  
  4. 配置防火墙,配置和启动服务
     1 sudo ufw allow 5900
     2 sudo systemctl enable x11vnc.service
     3 sudo systemctl daemon-reload
  5. 重启

脚本:

1 su root
2 wget https://github.com/longhr/ubuntu1604hub/raw/master/ubuntu1604VNC.sh
3 chmod u+x ubuntu1604VNC.sh
4 ./ubuntu1604VNC.sh

https://github.com/longhr/ubuntu1604hub/raw/master/ubuntu1604VNC.sh

 1 # #################################################################
 2 # 脚本名称 : ubuntu1604VNC
 3 # 脚本描述 : 自动安装配置和自动启动X11Vnc            
 4 # 编写日期 : 2016.6.13
 5 # 作    者 : longhr 
 6 # 作者网站 : blog.csdn.net/longhr
 7 # 软件版本 : 0.1
 8 # 注意事项: 运行完5秒内会重启
 9 # 免责声明 : 使用自由,后果自付 
10 # #################################################################
11 
12 # 步骤 1 - 安装 X11VNC  
13 # ################################################################# 
14 sudo apt-get install x11vnc -y
15 
16 # 步骤 2 - 配置访问密码
17 # ################################################################# 
18 
19 sudo x11vnc -storepasswd /etc/x11vnc.pass 
20 
21 
22 # 步骤 3 - 创建服务
23 # ################################################################# 
24 
25 cat > /lib/systemd/system/x11vnc.service << EOF
26 [Unit]
27 Description=Start x11vnc at startup.
28 After=multi-user.target
29 
30 [Service]
31 Type=simple
32 ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared
33 
34 [Install]
35 WantedBy=multi-user.target
36 EOF
37 
38 # 步骤 4 - 配配置防火墙端口,配置和启动服务
39 # ################################################################ 
40 
41 echo "Configure firewall"
42 sudo ufw allow 5900
43 echo "Configure Services"
44 sudo systemctl enable x11vnc.service
45 sudo systemctl daemon-reload
46 
47 # 步骤 5 - 重启
48 # ################################################################ 
49 sleep  5s
50 sudo shutdown -r now 
51 
52 
posted @ 2016-08-18 14:22  784040932  阅读(1844)  评论(0编辑  收藏  举报