PINE64
How to setup VNC on your Pine64 (Debian, SSH, headless) - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PINE A64(+) (https://forum.pine64.org/forumdisplay.php?fid=4)
+--- Forum: Pine A64 Projects, Ideas and Tutorials (https://forum.pine64.org/forumdisplay.php?fid=19)
+--- Thread: How to setup VNC on your Pine64 (Debian, SSH, headless) (/showthread.php?tid=794)

Pages: 1 2 3


How to setup VNC on your Pine64 (Debian, SSH, headless) - pine64nutz - 04-26-2016

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!


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - kiltman - 04-27-2016

Thank you for this post.  Smile 
It was very usefull for me.

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


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - pine64nutz - 04-27-2016

(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!


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - ibhoopin - 05-04-2016

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.


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - pine64nutz - 05-06-2016

(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.


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - pelgrim - 05-21-2016

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.


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - pine64nutz - 05-29-2016

(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.


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - pelgrim - 05-29-2016

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


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - hahn - 07-04-2016

Thanks! I've tried that on ubuntu 3.10.101-4-pine64-longsleep aarch64 and it worked. only change I made is user name.


RE: How to setup VNC on your Pine64 (Debian, SSH, headless) - MarkHaysHarris777 - 07-04-2016

(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