How to setup VNC on your Pine64 (Debian, SSH, headless)
#1
Since I couldn't find any info here about this I was thinking to write a little tutorial, maybe it going to help.

I got my Pine64 recently and I don't have any display or keyboard available so the only way to get desktop environment was over VNC (or RDP). This tutorial is for Debian 8 Jessie with MATE and how to VNC.

How to VNC

1: login into terminal via SSH

2: update server packages
Code:
sudo apt-get update

3: install vnc4server 
Code:
apt-get install vnc4server

4: create a password for your vnc server
Code:
vnc4passwd

5: setup the xstartup script to get mate environment on VNC
Code:
sudo nano ~/.vnc/xstartup
 
 overwrite with this code
Code:
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
-terminal-emulator -geometry 80x20+10+10 -ls -title "$VNCDESKTOP Desktop" &
mate-session &
mate-panel &

6: start the vnc server with vnc4server -geometry <resolution> -depth <16,24 whatever depth you want>
Code:
vnc4server -geometry 800x600 -depth 24
 
 you should get a message like this
Code:
New '<hostname>:1 (<your_username>)' desktop is <hostname>:1

Starting applications specified in /home/<your_username>/.vnc/xstartup
Log file is /home/<your_username>/.vnc/hostname:1.log

this means that a VNC server has started on your at port :1 (5901) if it said :2 in means port 5902 and so on...
user a VNC viewer (Real VNC, Ultra VNC) to login to your VNC server, usually is <your_local_ip>:5901 

If you get only a grey screen change the permissions on xstartup file

first stop the server 
Code:
vnc4server -kill :1

then
Code:
sudo chmod 755 xstartup

start the server again

Update #1
How to run VNC server as a service automatically

make sure you kill the server first
Code:
vnc4server -kill :1

make a new script where you can setup the VNC server
Code:
sudo nano /usr/local/bin/vncserver

paste the code bellow (here you can put your desired resolution and depth)
Code:
#!/bin/bash
PATH="$PATH:/usr/bin/"
DISPLAY="1"
DEPTH="24"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

case "$1" in
start)
/usr/bin/vnc4server ${OPTIONS}
;;

stop)
/usr/bin/vnc4server -kill :${DISPLAY}
;;

restart)
$0 stop
$0 start
;;
esac
exit 0

save the file and make it executable
Code:
sudo chmod +x /usr/local/bin/vncserver

now make a unit file, that will describe the service and tell the server how to work with the service
Code:
sudo nano /lib/systemd/system/vncserver.service

paste the code bellow (make sure to put your user under User=)
Code:
[Unit]
Description=Manage VNC Server

[Service]
Type=forking
ExecStart=/usr/local/bin/vncserver start
ExecStop=/usr/local/bin/vncserver stop
ExecReload=/usr/local/bin/vncserver restart
User=pine64user

[Install]
WantedBy=multi-user.target

reload systemctl and enable VNC server
Code:
sudo systemctl daemon-reload
sudo systemctl enable vncserver.service

reboot and see if it's works

Coming next: connect to VNC server over SSH.
Have fun!
  Reply


Messages In This Thread
How to setup VNC on your Pine64 (Debian, SSH, headless) - by pine64nutz - 04-26-2016, 08:06 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
Information Pine64 Head Unit Zoidiano0 100 32,742 11-19-2019, 04:35 AM
Last Post: rogatip79
  PINE64 to allow use of SATA disk on network/FTP mwelbourne 10 261 11-18-2019, 04:09 PM
Last Post: evilbunny
  Pine64 E-ink screen - Android projectileobjects 3 1,967 06-25-2019, 07:31 AM
Last Post: clamum
  Setup Pine64+ with OP-TEE stdys 0 344 09-13-2018, 03:23 PM
Last Post: stdys
Information UEFI for Pine64 z4v4l 20 4,958 06-24-2018, 03:06 PM
Last Post: z4v4l
  Domoticz + PINE64 Z-Wave Module + Open Z-Wave klliew 4 3,279 04-19-2018, 02:23 AM
Last Post: Harlan Mueller
  Pine64 as Security Camera / Baby Monitor utdrmac 2 2,035 02-01-2018, 07:49 AM
Last Post: davidbrucs
Photo Nextcloud running on Pine64 gbjensen 1 1,548 01-18-2018, 05:51 AM
Last Post: Luke
  smartphone based on a pine64 Little_Johnny 9 1,791 10-28-2017, 02:57 AM
Last Post: Little_Johnny
  Does my idea is possible ? Use of pinebook + rock64 + pine64 liochan 0 964 07-17-2017, 06:48 AM
Last Post: liochan

Forum Jump:


Users browsing this thread: 1 Guest(s)