安裝VNC server
sudo apt-get install tightvncserver
安裝完成後啟用:(第一次需設置密碼)
tightvncserver
root@raspberrypi:~# tightvncserver You will require a password to access your desktops. Password: Verify: Would you like to enter a view-only password (y/n)? y Password: Verify: New 'X' desktop is raspberrypi:1 Creating default startup script /root/.vnc/xstartup Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/raspberrypi:1.log root@raspberrypi:~# netstat -na | grep 5901 tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN
第一次啟動可以執行以下指令
vncserver
修改連線密碼
vncpasswd
建立一個開機自動啟動的 Script
sudo vi /etc/init.d/tightvnc
貼上下列內容
### BEGIN INIT INFO # Provides: vncserver # Required-Start: $networking # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start tightVNC Server ### END INIT INFO USER=pi case "$1" in start) echo "Starting VNC Server ..." su - $USER -c "/usr/bin/vncserver -geometry 1280x1024 -depth 16 :1" ;; stop) echo "Stopping VNC Server ..." su - $USER -c "/usr/bin/vncserver -kill :1 2> /dev/null" ;; restart) $0 stop sleep 1 $0 start ;; *) echo "$0 {start|stop|restart}" exit 1 ;; esac exit 0
上面的 geometry 參數用來指定解析度,depth 參數可以調色彩,可以依需求自行修改
讓 script 擁有可被執行的權限
sudo chmod +x /etc/init.d/tightvnc
設定成開機自動被啟動
sudo update-rc.d tightvnc defaults
使用vnc client端軟體登入預設port 5901
輸入剛才設定的密碼
登入成功