[Raspberry Pi] VNC远端

开启Terminal 安装VNC server [tightvncserver]
sudo apt-get install tightvncserver
启动 vncserver
vncserver

连线VNC sever时,可以有类似多桌命的功能,不同桌面利用不同port区分,且各桌面可以有各自的解析度,可以视连线电脑的银幕解析度来决定要连线到哪个解析度的桌面,使用这样设定须事前手动进行相关设定。
– 连线埠 (:NUM):例如设定 :1 开启的 port 为5901,:2 开启的 port 为5902,依此类推,预设为 :1。
– 解析度(geometry):例如 640×480, 800×600, 1024×768 等,预设为 1024×768。
– 像素深度(depth):例如 8, 16, 24 等,这是指每个像素可显示的位元数,预设为 16。

例如我们想设定 VNC 伺服器监听 5903 这个埠号,当有用户连线到 5903 后可开启一个 1024×768 65536的画面。
vncserver :3 -geometry 1024×768 -depth 16

让树莓派在开机时便启动VNC VNC server 服务,在 /etc/init.d/ 下建立一个script
,取名为 tightvncserver
sudo nano /etc/init.d/tightvncserver
script 如以下

#!/bin/bash### BEGIN INIT INFO# Provides:          tightvncserver# Required-Start:    $syslog# Required-Stop:     $syslog# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: vnc server# Description:### END INIT INFOexport USER='pi'eval cd ~$USER# Check the state of the command - this'll either be start or stop case "$1" in  start)    # if it's start, then start vncserver using the details below    su $USER -c '/usr/bin/vncserver :1 -geometry 1920x1080 -depth 16'    su $USER -c '/usr/bin/vncserver :2 -geometry 1280x720 -depth 16'    su $USER -c '/usr/bin/vncserver :3 -geometry 1024x768 -depth 16'    echo "Starting vncserver for $USER "    ;;  stop)    # if it's stop, then just kill the process    pkill Xtightvnc    echo "vncserver stopped"    ;;  *)    echo "Usage: /etc/init.d/tightvncserver {start|stop}"    exit 1    ;;esacexit 0

修改脚本权限
sudo chmod 755 /etc/init.d/tightvncserver
该脚本加入预设的启动程序。
sudo update-rc.d tightvncserver defaults


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章