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!
#2
Thank you for this post.  Smile 
It was very usefull for me.

Could you please add information about getting VNC automatically at startup?
#3
(04-27-2016, 07:36 AM)kiltman Wrote: Thank you for this post.  Smile 
It was very usefull for me.

Could you please add information about getting VNC automatically at startup?

Updated. Enjoy!
#4
Are you a part of the Reddit Pine64 sub?  If not, would you mind if I share your instructions?  I feel like this would be a valuable post there.
#5
(05-04-2016, 12:43 PM)ibhoopin Wrote: Are you a part of the Reddit Pine64 sub?  If not, would you mind if I share your instructions?  I feel like this would be a valuable post there.

I am not part of Pine64 sub, you can go ahead and share it.
#6
hi

this didn't work for me.
Can you tell me what information or command results I can post to diagnose the problem ?

I preformed the procedure under:
Update #1

How to run VNC server as a service automatically


I run the Ubuntu image provided on this forum and installed LXDE (not Mate).
Manual start of VNC works.
#7
Sad 
(05-21-2016, 07:38 AM)pelgrim Wrote: hi

this didn't work for me.
Can you tell me what information or command results I can post to diagnose the problem ?

I preformed the procedure under:
Update #1

How to run VNC server as a service automatically


I run the Ubuntu image provided on this forum and installed LXDE (not Mate).
Manual start of VNC works.

This tutorial is for Debian, for Ubuntu it's a different set of settings. You need to build a startup script in /etc/init.d/  and update the boot startup update-rc.d  in order to make it work. Haven't tried Ubuntu yet so I can't tell you for sure all the steps.
#8
Guess I forgot to report here, the matter was solved back then.

All I had to do was:
sudo apt-get install x11vnc
run gnome-session-properties
add: x11vnc -forever
#9
Thanks! I've tried that on ubuntu 3.10.101-4-pine64-longsleep aarch64 and it worked. only change I made is user name.
#10
(04-26-2016, 08:06 PM)pine64nutz Wrote: 3: install vnc4server 
Code:
apt-get install vnc4server
Thank you, pine64nutz !
I was not aware of vnc4server...  I have been trying (depserately) to get tightvncserver running on debian from the repos, and tightvncserver is (supposed) to work like vnc4server, but is seriously broken on debian; at least from the respos.
Anyway, vnc4server (Xvnc4) works great !,  again, thank you.
There is a baby bug if attaching from the mac (screen sharing) client. If the mouse cursor is 'inside' the xterminal frame then typing into the terminal will lock the interface !  Closing the vncviewer session and starting over unlocks...  so, the mouse cursor must be riding at the top of the terminal window but not resting inside it !

edit: PS I have only had the locking issue using twm (tiny window manager).

My gnu+linux vncviewer clients worked fine with Xvnc4 (vnc4server) as did the ssh tunnel and encrypted channel.
marcus


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pine64 as squeezebox touch replacement Learnincurve 12 29,879 01-13-2021, 02:11 AM
Last Post: Learnincurve
  Pine64 E-ink screen - Android projectileobjects 4 10,283 12-03-2020, 03:03 PM
Last Post: Silk
  Pine64 based IP KVM tuaris 0 4,202 08-06-2020, 12:05 AM
Last Post: tuaris
Information Pine64 Head Unit Zoidiano0 100 155,546 11-19-2019, 04:35 AM
Last Post: rogatip79
  PINE64 to allow use of SATA disk on network/FTP mwelbourne 10 17,238 11-18-2019, 04:09 PM
Last Post: evilbunny
  Setup Pine64+ with OP-TEE stdys 0 3,784 09-13-2018, 03:23 PM
Last Post: stdys
Information UEFI for Pine64 z4v4l 20 41,624 06-24-2018, 03:06 PM
Last Post: z4v4l
  Domoticz + PINE64 Z-Wave Module + Open Z-Wave klliew 4 10,424 04-19-2018, 02:23 AM
Last Post: Harlan Mueller
  Pine64 as Security Camera / Baby Monitor utdrmac 2 7,602 02-01-2018, 07:49 AM
Last Post: davidbrucs
Photo Nextcloud running on Pine64 gbjensen 1 6,418 01-18-2018, 05:51 AM
Last Post: Luke

Forum Jump:


Users browsing this thread: 2 Guest(s)