change vnc install to realvnc

This commit is contained in:
aiminick 2019-02-21 06:12:09 +08:00 committed by GitHub
parent 9e678f8847
commit d1c6ae8821
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 109 deletions

View File

@ -2,138 +2,64 @@
![openfans](../images/openfans.png)    ![amatfan.png](../images/amatfan.png)
        [OPENFANS开源社区](http://www.openfans.org)        [树莓派爱好者基地](http://rpifans.cn/)            **荣誉出品 **
        [OPENFANS开源社区](http://www.openfans.org)        [树莓派爱好者基地](http://www.pifan.org)            **荣誉出品 **
----
# 如何设置VNC远程访问
使用root账户登录并执行下列操作
使用root账户登录并执行下列操作
## 安装VNC
## 安装 RealVNC
```shell
apt update; sudo apt install tightvncserver -y
apt update
cd ~ ; wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.4.0-Linux-ARM.deb
apt install ./VNC-Server-6.4.0-Linux-ARM.deb
dpkg -i ./VNC-Server-6.4.0-Linux-ARM.deb
rm -rf ./VNC-Server-6.4.0-Linux-ARM.deb
```
然后注销或退出登录,在目录菜单 "**其他**" 里面可以找到 "**VNC Server**"
### 设置root用户VNC密码
```shell
vncserver
You will require a password to access your desktops.
Password: # 设置你的root账户的VNC访问密码
Verify: # 再次确认你的root账户的VNC访问密码
## 下面设置仅查看密码(无操作权限),这里不设置,所以选择"n"
Would you like to enter a view-only password (y/n)? n
```
VNC默认设置访问密码为你的账户密码用户名为你的账户名
### 结束VNC进程
### 设置成服务的方式启动
```shell
vncserver -kill :1
## 一些说明介绍:
Installed systemd unit for VNC Server in Service Mode daemon
Start or stop the service with:
systemctl (start|stop) vncserver-x11-serviced.service
Mark or unmark the service to be started at boot time with:
systemctl (enable|disable) vncserver-x11-serviced.service
Installed systemd unit for VNC Server in Virtual Mode daemon
Start or stop the service with:
systemctl (start|stop) vncserver-virtuald.service
Mark or unmark the service to be started at boot time with:
systemctl (enable|disable) vncserver-virtuald.service
```
### 设置root账户VNC配置文件
- 首先杀死进程确保用户手动没有启动VNC
```shell
mv /root/.vnc/xstartup /root/.vnc/xstartup.bak
## 编辑文件
vim /root/.vnc/xstartup
## 键入下面的内容
killall vncserver-x11-core vncserver-x11 vncagent vncserverui
```
- 然后根据提示,设置成服务并运行
```shell
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
systemctl enable vncserver-x11-serviced.service ; systemctl start vncserver-x11-serviced.service
```
### 启动检验再关闭退出
```shell
vncserver ; vncserver -kill :1
```
### 设置pi账户VNC配置文件
```shell
mkdir /home/pi/.vnc ; cp ~/.vnc/xstartup /home/pi/.vnc/xstartup ;\
chown -R pi /home/pi/.vnc ;\
adduser pi bluetooth
```
```shell
## 编辑文件
vim /etc/dbus-1/system.d/bluetooth.conf
#### 在"<!-- allow users of bluetooth group to communicate -->" 一行上加入以下内容
```
```shell
<policy group="pi">
<allow send_destination="org.bluez"/>
</policy>
## 下面一行不要添加,文件中应该存在
<!-- allow users of bluetooth group to communicate -->
```
### 设置pi用户VNC密码
```shell
su - pi
vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
vncserver -kill :1
exit
```
### 配置VNC服务文件
```shell
## 编辑文件
vim /lib/systemd/system/vncserver@.service
## 键入下面的内容
```
```shell
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=pi
Group=sudo
WorkingDirectory=/home/pi
PIDFile=/home/pi/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
```
### 激活和启动服务
```shell
systemctl daemon-reload; systemctl enable vncserver@1.service ;\
systemctl start vncserver@1.service ; systemctl status vncserver@1.service
```
### 客户端连接
1. 使用客户端连接到你的服务器IP地址:5901
2. 然后输入你设置的pi用户的VNC密码
- 运行后默认端口为:**5900**
----
@ -151,7 +77,7 @@ ln -sf /usr/share/novnc/vnc_auto.html /usr/share/novnc/index.html
### 启动服务
```shell
websockify -D --web=/usr/share/novnc/ --cert=/var/lib/shellinabox/certificate.pem 6080 localhost:5901
websockify -D --web=/usr/share/novnc/ --cert=/var/lib/shellinabox/certificate.pem 6080 localhost:5900
```
### 开机启动